@alipay/ams-checkout 0.0.1691995963-dev.1 → 0.0.1692935171-dev.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.
@@ -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,34 +15,24 @@ 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 { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } 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, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum, eventCodeEnum } from "../../types";
21
+ import { addSetFontSizeEvent, amsSetSize, getDesignFontSize, 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 { componentAddCSS, inlineComponentAddCss, showInlineLoading } from "./component.style";
27
25
  var _window = window,
28
26
  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
- };
27
+ var componentContainerId = 'ams-component-container';
28
+ var componentSectionId = 'ams-component-section';
29
+ var componentCloseBlockId = 'asm-component-close-block';
30
+ var componentRetentionId = 'ams-component-retention';
45
31
  var mockupId = 'ams-component-mockup';
46
32
  var loadingId = 'ams-component-loading';
47
33
  var listenerPrefix = '_ams_sdk_component_listener';
34
+ var inlineBaseStyleId = 'ams-inline-component-style';
35
+ var loadTimeLimit = 15000;
48
36
  var ComponentApp = /*#__PURE__*/function () {
49
37
  function ComponentApp() {
50
38
  _classCallCheck(this, ComponentApp);
@@ -57,22 +45,22 @@ var ComponentApp = /*#__PURE__*/function () {
57
45
  _defineProperty(this, "_appVersion", void 0);
58
46
  _defineProperty(this, "_isRetention", void 0);
59
47
  _defineProperty(this, "_actionQueryPromise", null);
48
+ _defineProperty(this, "_loadAppPromiseResolve", null);
60
49
  _defineProperty(this, "_renderParams", null);
61
- _defineProperty(this, "_componentName", '');
50
+ _defineProperty(this, "_componentSign", componentSignEnum.NONE);
62
51
  _defineProperty(this, "_performanceData", []);
63
52
  _defineProperty(this, "_isInitComponent", void 0);
64
53
  _defineProperty(this, "_clickEventName", void 0);
65
- this._appVersion = '1.3.1';
54
+ _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
55
+ this._appVersion = '1.5.1';
66
56
  this._isInitComponent = false;
67
- this._selector = '#ams-component-section';
57
+ this._selector = "#".concat(componentSectionId);
68
58
  this.createIframeNode = function () {
69
59
  return Promise.resolve();
70
60
  };
71
- this.platform = isPC() ? 'desktop' : 'mobile';
72
- this._clickEventName = this.platform === 'mobile' ? 'touchend' : 'click';
61
+ this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
62
+ this._clickEventName = this.platform === platformEnum.mobile ? 'touchend' : 'click';
73
63
  this._isRetention = true;
74
- addEvent();
75
- this.createMountElement();
76
64
  this._performanceData.push({
77
65
  key: 'sdk_init',
78
66
  value: Date.now()
@@ -85,7 +73,7 @@ var ComponentApp = /*#__PURE__*/function () {
85
73
  _createClass(ComponentApp, [{
86
74
  key: "logoutPlugin",
87
75
  value: function logoutPlugin() {
88
- this.closeCashier();
76
+ this.cleanContainer(true);
89
77
  }
90
78
 
91
79
  /**
@@ -103,8 +91,8 @@ var ComponentApp = /*#__PURE__*/function () {
103
91
  */
104
92
  }, {
105
93
  key: "setRender",
106
- value: function setRender(createIframeNode) {
107
- this.createIframeNode = createIframeNode;
94
+ value: function setRender(renderFunc) {
95
+ this.createIframeNode = renderFunc;
108
96
  }
109
97
 
110
98
  /**
@@ -112,89 +100,136 @@ var ComponentApp = /*#__PURE__*/function () {
112
100
  */
113
101
  }, {
114
102
  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);
103
+ value: function appendIframeNodes(componentSign, renderParams) {
104
+ var _this = this;
105
+ if (this._isInitComponent) {
106
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
107
+ return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
108
+ }
119
109
  this._isInitComponent = true;
120
110
  this._renderParams = renderParams;
121
- this._componentName = componentName;
111
+ this._componentSign = componentSign;
112
+ if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
113
+ this._renderDisplayType = renderParams.renderDisplayType;
114
+ var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(componentContainerId) : this._selector;
122
115
  this._performanceData.push({
123
116
  key: 'sdk_create_component',
124
117
  value: Date.now()
125
118
  });
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();
119
+ this.dispatchToSDK(EVENT.eventCallback.name, {
120
+ code: eventCodeEnum.SDK_START_OF_LOADING
121
+ });
122
+ if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
123
+ this.createInlineBaseElement(renderParams);
124
+ }
125
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
126
+ this.createBaseElement();
127
+ this.setContainerClass();
128
+ this.createRetentionPopup();
129
+ this.createMockup();
130
+ this.renderPopupLoading(renderParams);
134
131
  }
135
- this.showCashier();
136
132
  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 () {
133
+ return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this.createLoadAppPromise()]).then(function () {
134
+ return Promise.resolve();
135
+ }).catch(function (error) {
141
136
  _this._isInitComponent = false;
137
+ _this.cleanContainer();
138
+ return Promise.reject(error);
142
139
  });
143
140
  }
141
+ }, {
142
+ key: "renderPopupLoading",
143
+ value: function renderPopupLoading(renderParams) {
144
+ var _renderParams$appeara;
145
+ var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
146
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
147
+ if (!showLoading) return;
148
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
149
+ var mockup = document.getElementById(mockupId);
150
+ if (mockup) mockup.style.display = 'block';
151
+ return this.showPopupLoading();
152
+ }
153
+ }
154
+ }, {
155
+ key: "createLoadAppPromise",
156
+ value: function createLoadAppPromise() {
157
+ var _this2 = this;
158
+ return new Promise(function (resolve, reject) {
159
+ _this2._loadAppPromiseResolve = resolve;
160
+ setTimeout(function () {
161
+ reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
162
+ }, loadTimeLimit);
163
+ }).catch(function (error) {
164
+ _this2.dispatchToSDK(EVENT.error.name, {
165
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
166
+ message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
167
+ });
168
+ return Promise.reject(error);
169
+ });
170
+ }
171
+
144
172
  /**
145
173
  * @description Interface request
146
174
  */
147
175
  }, {
148
176
  key: "createActionQueryPromise",
149
177
  value: function createActionQueryPromise() {
150
- var _this2 = this;
178
+ var _this3 = this;
151
179
  this._performanceData.push({
152
180
  key: 'sdk_action_query_start',
153
181
  value: Date.now()
154
182
  });
155
183
  this._actionQueryPromise = new Promise(function (resolve, reject) {
156
- var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
184
+ var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
157
185
  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
186
+ paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
187
+ 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
188
  };
161
- if (componentNameEnum.card === _this2._componentName) {
189
+ /**
190
+ * @description card
191
+ */
192
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
162
193
  params.paymentMethodType = 'CARD';
163
194
  }
164
- if (componentNameEnum.easyPay === _this2._componentName) {
165
- var _this2$_renderParams4;
166
- // if EASY_PAY 2.0 , no need to query payment request
195
+ /**
196
+ * @description easyPay
197
+ */
198
+ if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
199
+ var _this3$_renderParams4;
167
200
  var _ref = params.paymentSessionConfig || {},
168
201
  _ref$productSceneVers = _ref.productSceneVersion,
169
202
  productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
170
203
  _ref$productScene = _ref.productScene,
171
204
  productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
172
- var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
205
+ var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
173
206
  _ref2$action = _ref2.action,
174
207
  _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
175
208
  _ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
176
209
  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
210
+ if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
211
+ // if EASY_PAY 2.0 , no need to query payment request
180
212
  return resolve({
181
- message: 'sdk no need to make query request'
213
+ message: 'sdk no need to make query request',
214
+ success: true
182
215
  });
183
216
  }
184
217
  }
185
218
  /**
186
219
  * @author tianqiang
187
- * @description 代扣逻辑处理
220
+ * @description autoDebit
188
221
  */
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) || '';
222
+ if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
223
+ var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
224
+ 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) || {};
225
+ 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
226
  if (signType === 'SMS') {
194
227
  return resolve({
195
- message: 'sdk no need to make query request'
228
+ message: 'sdk no need to make query request',
229
+ success: true
196
230
  });
197
- } else if (!signType || signType !== 'REDIRECT') {
231
+ }
232
+ if (!signType || signType !== 'REDIRECT') {
198
233
  return resolve({
199
234
  success: false
200
235
  });
@@ -204,14 +239,15 @@ var ComponentApp = /*#__PURE__*/function () {
204
239
  // mock
205
240
  if (isLocalMock()) {
206
241
  return resolve({
207
- message: 'sdk no need to make query request'
242
+ message: 'sdk no need to make query request',
243
+ success: true
208
244
  });
209
245
  }
210
246
  queryPaymentInfo(params, {
211
- env: _this2.AMSSDK.options.env.environment,
212
- locale: _this2.AMSSDK.options.locale
247
+ env: _this3.AMSSDK.options.env.environment,
248
+ locale: _this3.AMSSDK.options.locale
213
249
  }).then(function (res) {
214
- _this2._performanceData.push({
250
+ _this3._performanceData.push({
215
251
  key: 'sdk_action_query_end',
216
252
  value: Date.now()
217
253
  });
@@ -219,13 +255,15 @@ var ComponentApp = /*#__PURE__*/function () {
219
255
  resolve(res);
220
256
  } else {
221
257
  resolve(res);
222
- _this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
223
258
  }
224
259
  }).catch(function (err) {
260
+ _this3.dispatchToSDK(EVENT.error.name, {
261
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
262
+ });
225
263
  reject(err);
226
- _this2.closeCashier();
227
264
  });
228
265
  });
266
+ return this._actionQueryPromise;
229
267
  }
230
268
  }, {
231
269
  key: "cleanApp",
@@ -234,11 +272,13 @@ var ComponentApp = /*#__PURE__*/function () {
234
272
  this.app = null;
235
273
  this._removeEventListener();
236
274
  if (getType(this._selector) === 'string') {
237
- var dorpinDom = document.querySelector(this._selector);
238
- if (dorpinDom) dorpinDom.innerHTML = '';
275
+ var selectorDom = document.querySelector(this._selector);
276
+ if (selectorDom) selectorDom.innerHTML = '';
239
277
  }
240
278
  // eslint-disable-next-line no-empty
241
- } catch (error) {}
279
+ } catch (error) {
280
+ console.error(error);
281
+ }
242
282
  }
243
283
 
244
284
  /**
@@ -263,14 +303,13 @@ var ComponentApp = /*#__PURE__*/function () {
263
303
  this.appDomain = getAppDomain({
264
304
  environment: environment,
265
305
  appVersion: this._appVersion,
266
- componentName: this._componentName,
306
+ componentSign: this._componentSign,
267
307
  productSceneVersion: productSceneVersion,
268
308
  extendInfo: extendInfo
269
309
  });
270
- this.app = createIframe(this.AMSSDK.options.mode);
310
+ this.app = createIframe(this.AMSSDK.options.mode, this.platform);
271
311
  this.app.src = getIframeUrl({
272
- componentName: this._componentName,
273
- appearance: (renderParams === null || renderParams === void 0 ? void 0 : renderParams.appearance) || {},
312
+ componentSign: this._componentSign,
274
313
  analytics: this.AMSSDK.options.analytics,
275
314
  productSceneVersion: productSceneVersion,
276
315
  environment: environment,
@@ -309,7 +348,7 @@ var ComponentApp = /*#__PURE__*/function () {
309
348
  }, {
310
349
  key: "resizeListener",
311
350
  value: function resizeListener() {
312
- var cashier = document.getElementById('ams-component-container');
351
+ var cashier = document.getElementById(componentContainerId);
313
352
  cashier.style.transition = 'none';
314
353
  this.dispatchToApp({
315
354
  context: {
@@ -328,9 +367,9 @@ var ComponentApp = /*#__PURE__*/function () {
328
367
  }, {
329
368
  key: "_addEventListener",
330
369
  value: function _addEventListener() {
370
+ this._removeEventListener();
331
371
  window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
332
372
  window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
333
- this._removeEventListener();
334
373
  window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
335
374
  window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
336
375
  }
@@ -347,7 +386,7 @@ var ComponentApp = /*#__PURE__*/function () {
347
386
  }, {
348
387
  key: "_handleAppMessage",
349
388
  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];
389
+ 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];
351
390
  if (data.context.event === EVENT.dismissLoading.name) {
352
391
  var _data$context$data;
353
392
  this.dispatchToSDK(EVENT.eventCallback.name, {
@@ -364,13 +403,14 @@ var ComponentApp = /*#__PURE__*/function () {
364
403
  key: 'sdk_onLaunch',
365
404
  value: Date.now()
366
405
  });
406
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
367
407
  this.sendRenderEvent();
368
408
  return;
369
409
  }
370
410
  if (data.context.event === EVENT.sizeChanged.name) {
371
411
  this.handleSizeChanged(data);
372
412
  }
373
- if (data.context.event === EVENT.onClose.name) {
413
+ if (data.context.event === EVENT.close.name) {
374
414
  return this.closeBtnFunc();
375
415
  }
376
416
  if (data.context.event === EVENT.redirect.name) {
@@ -405,7 +445,10 @@ var ComponentApp = /*#__PURE__*/function () {
405
445
  key: "handleSizeChanged",
406
446
  value: function handleSizeChanged(data) {
407
447
  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) {
448
+ if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
449
+ var cashier = document.getElementById(componentContainerId);
450
+ cashier.style.height = "".concat(data.context.data.height, "px");
451
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
409
452
  var _document$getElementB;
410
453
  var mockup = document.getElementById(mockupId);
411
454
  if (mockup) {
@@ -414,20 +457,18 @@ var ComponentApp = /*#__PURE__*/function () {
414
457
  mockup.style.display = 'block';
415
458
  }
416
459
  (_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");
419
460
  if (this.platform === 'desktop') {
420
- cashier.classList.add('ams-component-container-desktop-animation');
461
+ cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
421
462
  if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
422
463
  }
423
464
  if (this.platform === 'mobile') {
424
- cashier.classList.add('ams-component-container-mobile-animation');
425
- var animationStyleId = 'ams-component-container-mobile-animation-style';
465
+ cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
466
+ var animationStyleId = "".concat(componentContainerId, "-").concat(this.platform, "-animation-style");
426
467
  var animationStyle = document.getElementById(animationStyleId);
427
468
  if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
428
469
 
429
470
  // 弹出和弹入动画
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 }");
471
+ var runkeyframes = "@keyframes ".concat(componentContainerId, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(componentContainerId, "-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
431
472
  // 创建style标签
432
473
  var style = document.createElement('style');
433
474
  style.id = animationStyleId;
@@ -443,17 +484,18 @@ var ComponentApp = /*#__PURE__*/function () {
443
484
  cashier.style.transition = 'height 0.28s ease-in-out';
444
485
  }, 500);
445
486
  }
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
487
  }
488
+ if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
489
+ var _document$getElementB2;
490
+ (_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
491
+ }
492
+ this.app.style.height = "".concat(data.context.data.height, "px");
493
+ this.app.style.opacity = '1';
451
494
  }
452
495
  }, {
453
496
  key: "handleRedirect",
454
497
  value: function handleRedirect(data) {
455
- var _this3 = this;
456
- this.closeCashier();
498
+ var _this4 = this;
457
499
  var _data = typeof data === 'string' ? {
458
500
  normalUrl: data
459
501
  } : {
@@ -463,37 +505,38 @@ var ComponentApp = /*#__PURE__*/function () {
463
505
  target: data === null || data === void 0 ? void 0 : data.target
464
506
  };
465
507
  var successCallback = function successCallback(type, url) {
466
- _this3.dispatchToSDK(EVENT.eventCallback.name, {
467
- code: 'SDK_CALL_URL_SUCCESS',
508
+ _this4.dispatchToSDK(EVENT.eventCallback.name, {
509
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
468
510
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
469
511
  });
470
512
  };
471
513
  var failCallback = function failCallback() {
472
- _this3.dispatchToSDK(EVENT.eventCallback.name, {
473
- code: 'SDK_CALL_URL_ERROR',
514
+ _this4.dispatchToSDK(EVENT.eventCallback.name, {
515
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
474
516
  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
517
  });
476
518
  };
477
519
 
478
520
  // 支持 target: _blank,新开tab页打开
479
- if (_data.target === Target.BLANK) {
521
+ if (_data.target === targetEnum.BLANK) {
480
522
  if (!_data.normalUrl) return failCallback();
481
523
  successCallback('normalUrl', _data.normalUrl);
482
524
  window.open(_data.normalUrl);
483
525
  return;
484
526
  }
527
+ this.cleanContainer();
485
528
  this.AMSSDK._redirect({
486
529
  applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
487
530
  }).then(function () {
488
531
  successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
489
532
  }).catch(function () {
490
- return _this3.AMSSDK._redirect({
533
+ return _this4.AMSSDK._redirect({
491
534
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
492
535
  });
493
536
  }).then(function () {
494
537
  successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
495
538
  }).catch(function () {
496
- return _this3.AMSSDK._redirect({
539
+ return _this4.AMSSDK._redirect({
497
540
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
498
541
  });
499
542
  }).then(function () {
@@ -509,21 +552,21 @@ var ComponentApp = /*#__PURE__*/function () {
509
552
  closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
510
553
  try {
511
554
  if (closeDialogData) {
512
- var retentionTitle = document.getElementById('ams-component-retention-title');
555
+ var retentionTitle = document.getElementById("".concat(componentRetentionId, "-title"));
513
556
  if (retentionTitle) {
514
557
  var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
515
558
  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
559
  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
560
  retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
518
561
  }
519
- var retentionMessage = document.getElementById('ams-component-retention-sub-title');
562
+ var retentionMessage = document.getElementById("".concat(componentRetentionId, "-sub-title"));
520
563
  if (retentionMessage) {
521
564
  var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
522
565
  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
566
  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
567
  retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
525
568
  }
526
- var remainBtn = document.getElementById('ams-component-retention-remain');
569
+ var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
527
570
  if (remainBtn) {
528
571
  var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
529
572
  remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
@@ -535,7 +578,7 @@ var ComponentApp = /*#__PURE__*/function () {
535
578
  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
579
  } 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
580
  }
538
- var leaveBrn = document.getElementById('ams-component-retention-leave');
581
+ var leaveBrn = document.getElementById("".concat(componentRetentionId, "-leave"));
539
582
  if (leaveBrn) {
540
583
  var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
541
584
  leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
@@ -555,11 +598,11 @@ var ComponentApp = /*#__PURE__*/function () {
555
598
  }, {
556
599
  key: "handleCloseBtnShow",
557
600
  value: function handleCloseBtnShow(showClose) {
558
- var closeBlock = document.getElementById('asm-component-section-close-block');
601
+ var closeBlock = document.getElementById(componentCloseBlockId);
559
602
  if (showClose) {
560
- closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove('asm-component-close-block-hidden');
603
+ closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(componentCloseBlockId, "-hidden"));
561
604
  } else if (showClose === false) {
562
- closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add('asm-component-close-block-hidden');
605
+ closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(componentCloseBlockId, "-hidden"));
563
606
  }
564
607
  }
565
608
 
@@ -569,7 +612,7 @@ var ComponentApp = /*#__PURE__*/function () {
569
612
  }, {
570
613
  key: "dispatchToSDK",
571
614
  value: function dispatchToSDK(event, data) {
572
- this.AMSSDK.eventCenter.emit(event, data);
615
+ this.AMSSDK._eventCenter.emit(event, data);
573
616
  }
574
617
 
575
618
  /**
@@ -585,8 +628,9 @@ var ComponentApp = /*#__PURE__*/function () {
585
628
  instanceId: this.AMSSDK._instanceId
586
629
  });
587
630
  if (this.app && this.app.contentWindow) {
588
- this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
631
+ return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
589
632
  }
633
+ throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
590
634
  }
591
635
 
592
636
  /**
@@ -599,7 +643,7 @@ var ComponentApp = /*#__PURE__*/function () {
599
643
  for (var key in eventKeyMap) {
600
644
  // eslint-disable-next-line no-prototype-builtins
601
645
  if (eventKeyMap.hasOwnProperty(key)) {
602
- this.AMSSDK.eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
646
+ this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
603
647
  }
604
648
  }
605
649
  }
@@ -611,7 +655,7 @@ var ComponentApp = /*#__PURE__*/function () {
611
655
  key: "sendRenderEvent",
612
656
  value: function () {
613
657
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
614
- var _this$_renderParams, _this$_renderParams2, res;
658
+ var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
615
659
  return _regeneratorRuntime().wrap(function _callee$(_context) {
616
660
  while (1) switch (_context.prev = _context.next) {
617
661
  case 0:
@@ -638,6 +682,8 @@ var ComponentApp = /*#__PURE__*/function () {
638
682
  sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
639
683
  paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
640
684
  heightOfVisible: Math.max(innerHeight, window.innerHeight),
685
+ renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
686
+ appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
641
687
  envInfo: {
642
688
  screenHeight: screen.height,
643
689
  screenWidth: screen.width
@@ -671,8 +717,8 @@ var ComponentApp = /*#__PURE__*/function () {
671
717
  return sendRenderEvent;
672
718
  }()
673
719
  }, {
674
- key: "showLoading",
675
- value: function showLoading() {
720
+ key: "showPopupLoading",
721
+ value: function showPopupLoading() {
676
722
  var loading = document.createElement('div');
677
723
  loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
678
724
  loading.id = loadingId;
@@ -686,47 +732,50 @@ var ComponentApp = /*#__PURE__*/function () {
686
732
  * @description show cashier
687
733
  */
688
734
  }, {
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));
735
+ key: "setContainerClass",
736
+ value: function setContainerClass() {
737
+ var cashier = document.getElementById(componentContainerId);
738
+ cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("".concat(componentContainerId, "-hidden-").concat(this.platform));
739
+ cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform));
694
740
  }
695
741
 
696
742
  /**
697
743
  * @description close cashier
698
744
  */
699
745
  }, {
700
- key: "closeCashier",
701
- value: function closeCashier() {
702
- var _document$getElementB2;
746
+ key: "cleanContainer",
747
+ value: function cleanContainer() {
748
+ var _document$getElementB3;
703
749
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
750
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
704
751
  this._performanceData = [];
705
752
  this._isInitComponent = false;
706
- (_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
753
+ (_document$getElementB3 = document.getElementById(loadingId)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
707
754
  this.hideComponentAndCleanDom(immediately);
708
755
  }
709
756
  }, {
710
757
  key: "hideComponentAndCleanDom",
711
758
  value: function hideComponentAndCleanDom() {
712
- var _this4 = this;
759
+ var _this5 = this;
713
760
  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));
761
+ var container = document.getElementById(componentContainerId);
762
+ if (container) {
763
+ // size变化动画取消
764
+ container.style.transition = '';
765
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-").concat(this.platform));
766
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
767
+ container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-hidden-").concat(this.platform));
768
+ }
720
769
  var removeMockupAndApp = function removeMockupAndApp() {
721
- var _document$getElementB3;
770
+ var _document$getElementB4;
722
771
  var body = document.getElementsByTagName('body')[0];
723
772
  body.style.overflow = 'auto';
724
773
  var mockup = document.getElementById(mockupId);
725
774
  mockup === null || mockup === void 0 ? void 0 : mockup.remove();
726
775
  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();
776
+ (_document$getElementB4 = document.getElementById("".concat(componentContainerId, "-").concat(_this5.platform, "-animation-style"))) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
777
+ _this5.removeRetentionPopup();
778
+ _this5.cleanApp();
730
779
  };
731
780
  if (immediately) removeMockupAndApp();else {
732
781
  setTimeout(function () {
@@ -739,8 +788,8 @@ var ComponentApp = /*#__PURE__*/function () {
739
788
  value: function closeBtnFunc() {
740
789
  // element && element.removeEventListener()
741
790
  if (this._isRetention) this.showRetentionPopup();else {
742
- this.closeCashier();
743
- this.dispatchToSDK(EVENT.onClose.name, {});
791
+ this.cleanContainer();
792
+ this.dispatchToSDK(EVENT.close.name, {});
744
793
  }
745
794
  }
746
795
 
@@ -748,33 +797,51 @@ var ComponentApp = /*#__PURE__*/function () {
748
797
  * @description create mount node
749
798
  */
750
799
  }, {
751
- key: "createMountElement",
752
- value: function createMountElement() {
800
+ key: "createBaseElement",
801
+ value: function createBaseElement() {
802
+ if (document.getElementById(componentContainerId)) return;
753
803
  componentAddCSS();
804
+ addSetFontSizeEvent();
754
805
  var amsComponentContainer = document.createElement('div');
755
- amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
756
- amsComponentContainer.id = 'ams-component-container';
806
+ amsComponentContainer.className = "".concat(componentContainerId, "-hidden-").concat(this.platform);
807
+ amsComponentContainer.id = componentContainerId;
757
808
  amsSetSize(null, amsComponentContainer);
758
809
  document.body.appendChild(amsComponentContainer);
759
810
  var amsComponentSection = document.createElement('div');
760
811
  amsComponentSection.className = "ams-component-section-".concat(this.platform);
761
- amsComponentSection.id = this._selector.slice(1);
812
+ amsComponentSection.id = componentSectionId;
762
813
  amsComponentContainer.appendChild(amsComponentSection);
763
814
  this.createCloseBtn();
764
815
  }
816
+ }, {
817
+ key: "createInlineBaseElement",
818
+ value: function createInlineBaseElement(renderParams) {
819
+ var _renderParams$appeara2;
820
+ var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
821
+ if (!inlineBaseStyle) inlineComponentAddCss();
822
+ if (document.getElementById(componentContainerId)) return;
823
+ var amsComponentContainer = document.createElement('div');
824
+ amsComponentContainer.className = "".concat(componentContainerId, "-inline");
825
+ amsComponentContainer.id = componentContainerId;
826
+ var selectorDom = document.querySelector(this._selector);
827
+ if (selectorDom) selectorDom.appendChild(amsComponentContainer);
828
+ var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
829
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
830
+ if (showLoading) showInlineLoading(amsComponentContainer, this.platform);
831
+ }
765
832
  }, {
766
833
  key: "createCloseBtn",
767
834
  value: function createCloseBtn() {
768
- var _this5 = this;
769
- var container = document.getElementById('ams-component-container');
835
+ var _this6 = this;
836
+ var container = document.getElementById(componentContainerId);
770
837
  // 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\"/>");
838
+ var closeBtnHTML = "<img class='".concat(componentCloseBlockId, "-btn-").concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
772
839
  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';
840
+ closeBlock.classList.add("".concat(componentCloseBlockId, "-").concat(this.platform), "".concat(componentCloseBlockId, "-hidden"));
841
+ closeBlock.id = componentCloseBlockId;
775
842
  closeBlock.innerHTML = closeBtnHTML;
776
843
  closeBlock.addEventListener(this._clickEventName, function () {
777
- _this5.closeBtnFunc();
844
+ _this6.closeBtnFunc();
778
845
  });
779
846
  if (container) container.appendChild(closeBlock);
780
847
  }
@@ -783,15 +850,15 @@ var ComponentApp = /*#__PURE__*/function () {
783
850
  value: function createRetentionPopup() {
784
851
  // retention popup
785
852
  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>");
853
+ retentionPopup.id = componentRetentionId;
854
+ retentionPopup.classList.add("".concat(componentRetentionId, "-").concat(this.platform));
855
+ retentionPopup.innerHTML = "\n <span id=\"".concat(componentRetentionId, "-title\" class=\"").concat(componentRetentionId, "-title-").concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"").concat(componentRetentionId, "-sub-title\"\n class=\"").concat(componentRetentionId, "-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"").concat(componentRetentionId, "-btn-block-").concat(this.platform, "\">\n <div id=\"").concat(componentRetentionId, "-remain\" class=\"").concat(componentRetentionId, "-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"").concat(componentRetentionId, "-leave\" class=\"").concat(componentRetentionId, "-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
789
856
  document.body.appendChild(retentionPopup);
790
- var remainBtn = document.getElementById('ams-component-retention-remain');
857
+ var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
791
858
  if (remainBtn) {
792
859
  remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
793
860
  }
794
- var leaveBtn = document.getElementById('ams-component-retention-leave');
861
+ var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
795
862
  if (leaveBtn) {
796
863
  leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
797
864
  }
@@ -799,47 +866,47 @@ var ComponentApp = /*#__PURE__*/function () {
799
866
  }, {
800
867
  key: "retentionPopupLeaveFunc",
801
868
  value: function retentionPopupLeaveFunc() {
802
- this.dispatchToSDK(EVENT.onClose.name, {});
869
+ this.dispatchToSDK(EVENT.close.name, {});
803
870
  this.hideRetentionPopup();
804
- this.closeCashier();
871
+ this.cleanContainer();
805
872
  }
806
873
  }, {
807
874
  key: "removeRetentionPopup",
808
875
  value: function removeRetentionPopup() {
809
- var _document$getElementB4;
810
- var remainBtn = document.getElementById('ams-component-retention-remain');
876
+ var _document$getElementB5;
877
+ var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
811
878
  if (remainBtn) {
812
879
  remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
813
880
  }
814
- var leaveBtn = document.getElementById('ams-component-retention-leave');
881
+ var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
815
882
  if (leaveBtn) {
816
883
  leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
817
884
  }
818
- (_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
885
+ (_document$getElementB5 = document.getElementById(componentRetentionId)) === null || _document$getElementB5 === void 0 ? void 0 : _document$getElementB5.remove();
819
886
  }
820
887
  }, {
821
888
  key: "showRetentionPopup",
822
889
  value: function showRetentionPopup() {
823
- var retentionPopup = document.getElementById('ams-component-retention');
824
- var container = document.getElementById('ams-component-container');
890
+ var retentionPopup = document.getElementById(componentRetentionId);
891
+ var container = document.getElementById(componentContainerId);
825
892
  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');
893
+ container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-opacity"));
894
+ retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
895
+ retentionPopup.classList.add("".concat(componentRetentionId, "-show"));
829
896
  }
830
897
  }
831
898
  }, {
832
899
  key: "hideRetentionPopup",
833
900
  value: function hideRetentionPopup() {
834
- var retentionPopup = document.getElementById('ams-component-retention');
835
- var container = document.getElementById('ams-component-container');
901
+ var retentionPopup = document.getElementById(componentRetentionId);
902
+ var container = document.getElementById(componentContainerId);
836
903
  if (retentionPopup) {
837
- retentionPopup.classList.remove('ams-component-retention-show');
838
- retentionPopup.classList.add('ams-component-retention-hidden');
904
+ retentionPopup.classList.remove("".concat(componentRetentionId, "-show"));
905
+ retentionPopup.classList.add("".concat(componentRetentionId, "-hidden"));
839
906
  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);
907
+ retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
908
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-opacity"));
909
+ }, 300);
843
910
  }
844
911
  }
845
912
  /**
@@ -882,7 +949,6 @@ var ComponentApp = /*#__PURE__*/function () {
882
949
  form.setAttribute('action', attributes.action);
883
950
  form.setAttribute('method', 'post');
884
951
  body.appendChild(form);
885
- this.closeCashier(true);
886
952
  setTimeout(function () {
887
953
  form.submit();
888
954
  }, 0);