@alipay/ams-checkout 1.30.0 → 1.31.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 (37) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +7 -7
  3. package/esm/config/index.js +7 -7
  4. package/esm/core/component/element/components/address.d.ts +1 -1
  5. package/esm/core/component/element/components/address.js +2 -2
  6. package/esm/core/component/element/components/payment.d.ts +1 -1
  7. package/esm/core/component/element/components/payment.js +2 -2
  8. package/esm/core/component/element/index.d.ts +7 -6
  9. package/esm/core/component/element/index.js +287 -222
  10. package/esm/core/component/element/type.d.ts +171 -12
  11. package/esm/core/component/element/type.js +48 -3
  12. package/esm/core/component/index.js +5 -0
  13. package/esm/core/instance/index.js +12 -1
  14. package/esm/foundation/index.d.ts +1 -1
  15. package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -2
  16. package/esm/foundation/product-processor/easysafepay/index.js +29 -73
  17. package/esm/foundation/service/container/index.d.ts +0 -2
  18. package/esm/foundation/service/container/index.js +20 -47
  19. package/esm/foundation/utils/payment_product_utils.d.ts +1 -1
  20. package/esm/foundation/utils/payment_product_utils.js +2 -2
  21. package/esm/foundation/utils/preload_helper.d.ts +21 -0
  22. package/esm/foundation/utils/preload_helper.js +143 -0
  23. package/esm/index.d.ts +7 -2
  24. package/esm/index.js +94 -7
  25. package/esm/plugin/component/index.d.ts +1 -0
  26. package/esm/plugin/component/index.js +24 -11
  27. package/esm/service/index.d.ts +0 -1
  28. package/esm/service/index.js +0 -2
  29. package/esm/types/index.d.ts +8 -117
  30. package/esm/types/index.js +2 -34
  31. package/esm/util/security.d.ts +1 -0
  32. package/esm/util/security.js +3 -1
  33. package/esm/util/spm-map.d.ts +3 -0
  34. package/esm/util/spm-map.js +3 -0
  35. package/package.json +1 -1
  36. package/esm/service/element.d.ts +0 -4
  37. package/esm/service/element.js +0 -51
@@ -8,7 +8,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
9
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  import { DisplayTypeEnum } from "../../../types";
11
- import { createIframe, createPreloadIframe, startSizeChangeAnim } from "./utils";
11
+ import { createIframe, startSizeChangeAnim } from "./utils";
12
12
  import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
13
13
  import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
14
14
  import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, LOADING_ID, MOCKUP_ID } from "../../../constant";
@@ -88,33 +88,6 @@ export var ContainerService = /*#__PURE__*/function () {
88
88
  // animation
89
89
  (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
90
90
  }
91
- }, {
92
- key: "preload",
93
- value: function preload(taskId, url) {
94
- var _this = this;
95
- var preloadIframe = createPreloadIframe(taskId);
96
- preloadIframe.src = url;
97
- var body = document.body || null;
98
- if (body) {
99
- body.appendChild(preloadIframe);
100
- }
101
- var timerId = setTimeout(function () {
102
- _this.clearPreloadContainer(taskId);
103
- }, MAX_CLEAR_TIME);
104
- this.clearTimerIdMapping[taskId] = timerId;
105
- }
106
- }, {
107
- key: "clearPreloadContainer",
108
- value: function clearPreloadContainer(taskId) {
109
- var timerId = this.clearTimerIdMapping[taskId];
110
- if (timerId) {
111
- clearTimeout(timerId);
112
- }
113
- var container = document.getElementById(taskId);
114
- if (container) {
115
- document.body.removeChild(container);
116
- }
117
- }
118
91
  }, {
119
92
  key: "showLoading",
120
93
  value: function showLoading(container, displayInfo) {
@@ -168,13 +141,13 @@ export var ContainerService = /*#__PURE__*/function () {
168
141
  }, {
169
142
  key: "addCapabilityToEventCenter",
170
143
  value: function addCapabilityToEventCenter() {
171
- var _this2 = this;
144
+ var _this = this;
172
145
  this.eventCenter.listen(EVENT.dismissLoading.name, function () {
173
- _this2.dismissLoading();
146
+ _this.dismissLoading();
174
147
  });
175
148
  this.eventCenter.listen(EVENT.getUserAgentFromSdk.name, function (data, payload) {
176
149
  var _payload$context;
177
- _this2.eventCenter.dispatchToApp({
150
+ _this.eventCenter.dispatchToApp({
178
151
  event: 'appEventCallback',
179
152
  eventCallbackId: (_payload$context = payload.context) === null || _payload$context === void 0 ? void 0 : _payload$context.eventCallbackId,
180
153
  data: {
@@ -183,34 +156,34 @@ export var ContainerService = /*#__PURE__*/function () {
183
156
  });
184
157
  });
185
158
  this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
186
- var _this2$displayInfo;
159
+ var _this$displayInfo2;
187
160
  if (data.paymentElementOldModel) return;
188
- _this2.popupManager.popup(_objectSpread({
189
- platform: (_this2$displayInfo = _this2.displayInfo) === null || _this2$displayInfo === void 0 ? void 0 : _this2$displayInfo.platform
161
+ _this.popupManager.popup(_objectSpread({
162
+ platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
190
163
  }, data)).catch(function (error) {
191
- _this2.logService.logError({
164
+ _this.logService.logError({
192
165
  title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
193
166
  }, error);
194
- _this2.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
167
+ _this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
195
168
  });
196
169
  });
197
170
  this.eventCenter.listen(EVENT.popWindow.name, function () {
198
- _this2.popupManager.pop();
171
+ _this.popupManager.pop();
199
172
  });
200
173
  this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
201
- _this2.handleSizeChanged(_objectSpread({}, data));
174
+ _this.handleSizeChanged(_objectSpread({}, data));
202
175
  });
203
176
  this.eventCenter.listen(EVENT.showCloseButton.name, function () {
204
- _this2.changeCloseBtnVisibility(true);
177
+ _this.changeCloseBtnVisibility(true);
205
178
  });
206
179
  this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
207
- _this2.changeCloseBtnVisibility(false);
180
+ _this.changeCloseBtnVisibility(false);
208
181
  });
209
182
  this.eventCenter.listen(EVENT.setMaskCloseButton.name, function (data) {
210
- _this2.handleMaskCloseBtnShow(data);
183
+ _this.handleMaskCloseBtnShow(data);
211
184
  });
212
185
  this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
213
- _this2.handleAppHeartBeat();
186
+ _this.handleAppHeartBeat();
214
187
  });
215
188
  }
216
189
  }, {
@@ -271,12 +244,12 @@ export var ContainerService = /*#__PURE__*/function () {
271
244
  }, {
272
245
  key: "handleAppHeartBeat",
273
246
  value: function handleAppHeartBeat() {
274
- var _this3 = this;
247
+ var _this2 = this;
275
248
  try {
276
249
  if (!this._webAppHeartBeatTimeoutFn) {
277
250
  this._webAppHeartBeatTimeoutFn = function () {
278
- if (_this3.webApp && _this3.displayInfo) {
279
- _this3.logService.logError({
251
+ if (_this2.webApp && _this2.displayInfo) {
252
+ _this2.logService.logError({
280
253
  title: 'sdk_error_appHeartBeatTimeout'
281
254
  });
282
255
  }
@@ -290,8 +263,8 @@ export var ContainerService = /*#__PURE__*/function () {
290
263
  window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
291
264
  }
292
265
  setTimeout(function () {
293
- if (_this3.webApp && _this3.displayInfo) {
294
- _this3.eventCenter.dispatchToApp({
266
+ if (_this2.webApp && _this2.displayInfo) {
267
+ _this2.eventCenter.dispatchToApp({
295
268
  event: 'sdkHeartBeat',
296
269
  data: {}
297
270
  });
@@ -5,7 +5,7 @@ export declare class ProductInfoCacheUtil {
5
5
  paymentMethodCategoryType: string;
6
6
  hostSign: string;
7
7
  }): void;
8
- static getPreviousProductInfo(productScene: ProductSceneEnum, onError: (msg: string) => void): {
8
+ static getPreviousProductInfo(productScene: ProductSceneEnum): {
9
9
  productSceneVersion: string;
10
10
  paymentMethodCategoryType: string;
11
11
  hostSign: string;
@@ -21,14 +21,14 @@ export var ProductInfoCacheUtil = /*#__PURE__*/function () {
21
21
  }
22
22
  }, {
23
23
  key: "getPreviousProductInfo",
24
- value: function getPreviousProductInfo(productScene, onError) {
24
+ value: function getPreviousProductInfo(productScene) {
25
25
  var key = KEY_PREVIOUS_PRODUCT_INFO + '_' + productScene;
26
26
  var previousProductInfoString = localStorage.getItem(key);
27
27
  if (previousProductInfoString) {
28
28
  try {
29
29
  return JSON.parse(previousProductInfoString);
30
30
  } catch (error) {
31
- onError(error === null || error === void 0 ? void 0 : error.message);
31
+ return null;
32
32
  }
33
33
  }
34
34
  return null;
@@ -0,0 +1,21 @@
1
+ import { PaymentMethodCategoryTypeEnum, ProductSceneEnum } from "../../types";
2
+ import { Security } from '../../util/security';
3
+ export default class PreloadHelper {
4
+ static isWebAppPreloaded: boolean;
5
+ static isSecuritySDKPreloaded: boolean;
6
+ private static securitySdkMap;
7
+ static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
8
+ static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
+ static getSecuritySdk(scene: any): Security;
10
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
11
+ preloadUrl: string;
12
+ containerId: string;
13
+ };
14
+ /**
15
+ * @description Obtain risk control configuration in local storage
16
+ */
17
+ static getSecurityConfigStorage(product: ProductSceneEnum): {
18
+ scene: string;
19
+ h5gateway: string;
20
+ };
21
+ }
@@ -0,0 +1,143 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import { sdkVersion } from "../../config";
9
+ import { createPreloadIframe } from "../service/container/utils";
10
+ import { ProductSceneEnum } from "../../types";
11
+ import { getWebAppUrl } from "../utils/web_app_url_utils";
12
+ import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
13
+ import { getWebAppVersion } from "./payment_context_utils";
14
+ import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
15
+ import { getOrSetStorageId, safeJson } from "../../util";
16
+ var MAX_CLEAR_TIME = 10000;
17
+ var PreloadHelper = /*#__PURE__*/function () {
18
+ function PreloadHelper() {
19
+ _classCallCheck(this, PreloadHelper);
20
+ }
21
+ _createClass(PreloadHelper, null, [{
22
+ key: "preloadWebApp",
23
+ value: function preloadWebApp(productScene, paymentMethodCategoryType) {
24
+ var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
25
+ try {
26
+ if (this.isWebAppPreloaded) {
27
+ console.log('[web-sdk] web app already preloaded');
28
+ return;
29
+ }
30
+ var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
31
+ preloadUrl = _this$buildWebAppPrel.preloadUrl,
32
+ containerId = _this$buildWebAppPrel.containerId;
33
+ var preloadIframe = createPreloadIframe(containerId);
34
+ preloadIframe.src = preloadUrl;
35
+ var body = document.body || null;
36
+ if (body) {
37
+ console.log('[web-sdk] preload web app, url: ', preloadUrl);
38
+ body.appendChild(preloadIframe);
39
+ this.isWebAppPreloaded = true;
40
+ }
41
+ setTimeout(function () {
42
+ var container = document.getElementById(containerId);
43
+ if (container) {
44
+ console.log('[web-sdk] remove preload web app');
45
+ document.body.removeChild(container);
46
+ }
47
+ }, MAX_CLEAR_TIME);
48
+ } catch (error) {
49
+ console.error('[web-sdk] preload web app failed', error);
50
+ }
51
+ }
52
+ }, {
53
+ key: "preloadSecuritySDK",
54
+ value: function preloadSecuritySDK(product) {
55
+ var _this = this;
56
+ var securityRegion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'SG';
57
+ try {
58
+ if (this.isSecuritySDKPreloaded) {
59
+ console.log('[web-sdk] security sdk is already loaded');
60
+ return;
61
+ }
62
+ var storage = PreloadHelper.getSecurityConfigStorage(product);
63
+ var scene = storage.scene || getSecurityScene(product);
64
+ console.log('getSecurityScene', scene);
65
+ var h5gateway = storage.h5gateway || getSecurityHost(securityRegion);
66
+ console.log('preloadSecuritySDK', scene);
67
+ var securitySdk = new Security({
68
+ scene: scene,
69
+ h5gateway: h5gateway
70
+ });
71
+ securitySdk.initSecurity(function () {
72
+ console.log(_this.securitySdkMap, 'this.securitySdkMap');
73
+ _this.securitySdkMap.set(scene, securitySdk);
74
+ _this.isSecuritySDKPreloaded = true;
75
+ console.log('[web-sdk] preload security sdk succeed');
76
+ }, function () {
77
+ console.error('[web-sdk] preload security sdk failed');
78
+ });
79
+ } catch (error) {
80
+ console.error('[web-sdk] preload security sdk failed', error);
81
+ }
82
+ }
83
+ }, {
84
+ key: "getSecuritySdk",
85
+ value: function getSecuritySdk(scene) {
86
+ var result = this.securitySdkMap.get(scene);
87
+ return result;
88
+ }
89
+ }, {
90
+ key: "buildWebAppPreloadUrl",
91
+ value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
92
+ var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
93
+ var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
94
+ if (previousProductInfo) {
95
+ productSceneVersion = previousProductInfo === null || previousProductInfo === void 0 ? void 0 : previousProductInfo.productSceneVersion;
96
+ }
97
+ var containerId = "ams-checkout-component-".concat(productScene, "_").concat(paymentMethodCategoryType);
98
+ var sdkMetaData = {
99
+ productScene: productScene,
100
+ sdkVersion: sdkVersion,
101
+ webAppVersion: ''
102
+ };
103
+ sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
104
+ var preloadUrl = getWebAppUrl({
105
+ environment: environment,
106
+ sdkMetaData: sdkMetaData,
107
+ paymentMethodCategoryType: paymentMethodCategoryType,
108
+ isPreload: true,
109
+ productSceneVersion: productSceneVersion,
110
+ query: undefined
111
+ });
112
+ return {
113
+ preloadUrl: preloadUrl,
114
+ containerId: containerId
115
+ };
116
+ }
117
+
118
+ /**
119
+ * @description Obtain risk control configuration in local storage
120
+ */
121
+ }, {
122
+ key: "getSecurityConfigStorage",
123
+ value: function getSecurityConfigStorage(product) {
124
+ var scene = '';
125
+ var h5gateway = '';
126
+ var securityConfigStorage = getOrSetStorageId(getSecurityConfigStorageKey(product));
127
+ if (securityConfigStorage) {
128
+ var config = safeJson(securityConfigStorage, {});
129
+ scene = config === null || config === void 0 ? void 0 : config.appName;
130
+ h5gateway = config === null || config === void 0 ? void 0 : config.h5gateway;
131
+ }
132
+ return {
133
+ scene: scene,
134
+ h5gateway: h5gateway
135
+ };
136
+ }
137
+ }]);
138
+ return PreloadHelper;
139
+ }();
140
+ _defineProperty(PreloadHelper, "isWebAppPreloaded", false);
141
+ _defineProperty(PreloadHelper, "isSecuritySDKPreloaded", false);
142
+ _defineProperty(PreloadHelper, "securitySdkMap", new Map());
143
+ export { PreloadHelper as default };
package/esm/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AddressComponent } from './core/component/address';
2
2
  import { ElementComponent } from './core/component/element';
3
3
  import { AMSComponent } from './core/component/index';
4
- import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams } from './types';
4
+ import { ComponentSignEnum, IcreateComponent, IElementOptions, IoptionsAddressParams, IoptionsParams, IPreloadOptions } from './types';
5
5
  export { AMSCheckoutPage } from './core/component/ckp';
6
6
  export * from './types';
7
7
  export declare class AMSCheckout extends AMSComponent {
@@ -9,15 +9,19 @@ export declare class AMSCheckout extends AMSComponent {
9
9
  }
10
10
  export declare class AMSAutoDebit extends AMSCheckout {
11
11
  constructor(options: IoptionsParams);
12
+ static preload(options?: IPreloadOptions): void;
12
13
  }
13
14
  export declare class AMSAutoDebitPay extends AMSCheckout {
14
15
  constructor(options: IoptionsParams);
16
+ static preload(options?: IPreloadOptions): void;
15
17
  }
16
18
  export declare class AMSCashierPayment extends AMSCheckout {
17
19
  constructor(options: IoptionsParams);
20
+ static preload(options?: IPreloadOptions): void;
18
21
  }
19
22
  export declare class AMSVaulting extends AMSCheckout {
20
23
  constructor(options: IoptionsParams);
24
+ static preload(options?: IPreloadOptions): void;
21
25
  }
22
26
  export declare class AntomElement extends AMSCheckout {
23
27
  constructor(options: IoptionsParams);
@@ -28,10 +32,11 @@ export declare class AddressElement extends AddressComponent {
28
32
  export declare class Element extends ElementComponent {
29
33
  constructor(options: IElementOptions);
30
34
  }
31
- export default AMSCheckout;
32
35
  export declare class AMSEasyPay {
33
36
  private core;
34
37
  constructor(options: IoptionsParams);
38
+ static preload(options?: IPreloadOptions): void;
35
39
  createComponent(params: IcreateComponent): void;
36
40
  unmount(): void;
37
41
  }
42
+ export default AMSCheckout;
package/esm/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
2
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -25,9 +28,10 @@ import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppV
25
28
  import { AddressComponent } from "./core/component/address";
26
29
  import { ElementComponent } from "./core/component/element";
27
30
  import { AMSComponent } from "./core/component/index";
28
- import { ComponentSignEnum, DisplayTypeEnum } from "./types";
31
+ import { ComponentSignEnum, DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from "./types";
29
32
  import { ProductSceneEnum } from "./types/index";
30
33
  import { LogConfig, Logger } from "./util/logger";
34
+ import PreloadHelper from "./foundation/utils/preload_helper";
31
35
  var logger = new Logger(LogConfig, true);
32
36
  export { AMSCheckoutPage } from "./core/component/ckp";
33
37
  export * from "./types";
@@ -59,7 +63,18 @@ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
59
63
  });
60
64
  return _super2.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_WALLET]);
61
65
  }
62
- return _createClass(AMSAutoDebit);
66
+ _createClass(AMSAutoDebit, null, [{
67
+ key: "preload",
68
+ value: function preload() {
69
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
70
+ securityRegion: 'SG',
71
+ environment: 'prod'
72
+ };
73
+ PreloadHelper.preloadWebApp(ProductSceneEnum.AUTO_DEBIT, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
74
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.AUTO_DEBIT, options.securityRegion);
75
+ }
76
+ }]);
77
+ return AMSAutoDebit;
63
78
  }(AMSCheckout);
64
79
  export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
65
80
  _inherits(AMSAutoDebitPay, _AMSCheckout2);
@@ -71,7 +86,18 @@ export var AMSAutoDebitPay = /*#__PURE__*/function (_AMSCheckout2) {
71
86
  });
72
87
  return _super3.call(this, _options, [ComponentSignEnum.AUTO_DEBIT_PAY_WALLET]);
73
88
  }
74
- return _createClass(AMSAutoDebitPay);
89
+ _createClass(AMSAutoDebitPay, null, [{
90
+ key: "preload",
91
+ value: function preload() {
92
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
93
+ securityRegion: 'SG',
94
+ environment: 'prod'
95
+ };
96
+ PreloadHelper.preloadWebApp(ProductSceneEnum.AUTO_DEBIT_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
97
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.AUTO_DEBIT_PAY, options.securityRegion);
98
+ }
99
+ }]);
100
+ return AMSAutoDebitPay;
75
101
  }(AMSCheckout);
76
102
  export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
77
103
  _inherits(AMSCashierPayment, _AMSCheckout3);
@@ -103,7 +129,48 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
103
129
  }
104
130
  return _super4.call(this, _options, currentChannelType);
105
131
  }
106
- return _createClass(AMSCashierPayment);
132
+ _createClass(AMSCashierPayment, null, [{
133
+ key: "preload",
134
+ value: function preload() {
135
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
136
+ securityRegion: 'SG',
137
+ environment: 'prod'
138
+ };
139
+ try {
140
+ var channelTypes;
141
+ var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
142
+ var previousChannel = JSON.parse(previousChannelStr) || {};
143
+ var _ref2 = previousChannel || {},
144
+ _ref2$channelType = _ref2.channelType,
145
+ channelType = _ref2$channelType === void 0 ? '' : _ref2$channelType;
146
+ if (ComponentSignEnum.CASHIER_PAYMENT_CARD === channelType) {
147
+ channelTypes = [PaymentMethodCategoryTypeEnum.CARD];
148
+ } else if (ComponentSignEnum.CASHIER_PAYMENT_APM === channelType) {
149
+ channelTypes = [PaymentMethodCategoryTypeEnum.APM];
150
+ } else if (ComponentSignEnum.CASHIER_PAYMENT_BANK === channelType) {
151
+ channelTypes = [PaymentMethodCategoryTypeEnum.BANK];
152
+ } else {
153
+ channelTypes = [PaymentMethodCategoryTypeEnum.CARD, PaymentMethodCategoryTypeEnum.APM];
154
+ }
155
+ var _iterator = _createForOfIteratorHelper(channelTypes),
156
+ _step;
157
+ try {
158
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
159
+ var _channelType = _step.value;
160
+ PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, _channelType, options.environment);
161
+ }
162
+ } catch (err) {
163
+ _iterator.e(err);
164
+ } finally {
165
+ _iterator.f();
166
+ }
167
+ } catch (error) {
168
+ console.error('[web-sdk] preload web app error', error);
169
+ }
170
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.CASHIER_PAYMENT, options.securityRegion);
171
+ }
172
+ }]);
173
+ return AMSCashierPayment;
107
174
  }(AMSCheckout);
108
175
  export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
109
176
  _inherits(AMSVaulting, _AMSCheckout4);
@@ -116,7 +183,18 @@ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout4) {
116
183
  });
117
184
  return _super5.call(this, _options, [ComponentSignEnum.CASHIER_PAYMENT_CARD]);
118
185
  }
119
- return _createClass(AMSVaulting);
186
+ _createClass(AMSVaulting, null, [{
187
+ key: "preload",
188
+ value: function preload() {
189
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
190
+ securityRegion: 'SG',
191
+ environment: 'prod'
192
+ };
193
+ PreloadHelper.preloadWebApp(ProductSceneEnum.CASHIER_PAYMENT, PaymentMethodCategoryTypeEnum.CARD, options.environment);
194
+ PreloadHelper.preloadSecuritySDK(ProductSceneEnum.VAULTING, options.securityRegion);
195
+ }
196
+ }]);
197
+ return AMSVaulting;
120
198
  }(AMSCheckout);
121
199
  export var AntomElement = /*#__PURE__*/function (_AMSCheckout5) {
122
200
  _inherits(AntomElement, _AMSCheckout5);
@@ -157,7 +235,6 @@ export var Element = /*#__PURE__*/function (_ElementComponent) {
157
235
  }
158
236
  return _createClass(Element);
159
237
  }(ElementComponent);
160
- export default AMSCheckout;
161
238
  export var AMSEasyPay = /*#__PURE__*/function () {
162
239
  function AMSEasyPay(options) {
163
240
  _classCallCheck(this, AMSEasyPay);
@@ -186,6 +263,16 @@ export var AMSEasyPay = /*#__PURE__*/function () {
186
263
  value: function unmount() {
187
264
  this.core.destroy();
188
265
  }
266
+ }], [{
267
+ key: "preload",
268
+ value: function preload() {
269
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
270
+ securityRegion: 'SG',
271
+ environment: 'prod'
272
+ };
273
+ PreloadHelper.preloadWebApp(ProductSceneEnum.EASY_PAY, PaymentMethodCategoryTypeEnum.WALLET, options.environment);
274
+ }
189
275
  }]);
190
276
  return AMSEasyPay;
191
- }();
277
+ }();
278
+ export default AMSCheckout;
@@ -79,6 +79,7 @@ export default class ComponentApp {
79
79
  */
80
80
  private addEventListener;
81
81
  private removeEventListener;
82
+ private elementEventCallback;
82
83
  /**
83
84
  * @description Processing messages from iframe
84
85
  */
@@ -23,6 +23,7 @@ import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK
23
23
  import { queryPaymentInfo, submitPayInfo } from "../../service";
24
24
  import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
25
25
  import { getType, isJsonString, isPC } from "../../util";
26
+ import { ElementPaymentMethod } from "../../core/component/element/type";
26
27
  import { getBackScheme } from "../../util/getBackScheme";
27
28
  import { isLocalMock } from "../../util/mock";
28
29
  import { matchVersion } from "../../util/versionCompare";
@@ -1168,15 +1169,26 @@ var ComponentApp = /*#__PURE__*/function () {
1168
1169
  window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
1169
1170
  }
1170
1171
 
1172
+ // element payment event callback回调码
1173
+ }, {
1174
+ key: "elementEventCallback",
1175
+ value: function elementEventCallback(data) {
1176
+ var _data$context, _data$context2;
1177
+ if (data.context.event === EVENT.sendMuitiAppEventToSdk.name && ((_data$context = data.context) === null || _data$context === void 0 || (_data$context = _data$context.data) === null || _data$context === void 0 ? void 0 : _data$context.source) === ElementPaymentMethod.PAYMENT_ELEMENT && ((_data$context2 = data.context) === null || _data$context2 === void 0 || (_data$context2 = _data$context2.data) === null || _data$context2 === void 0 ? void 0 : _data$context2.target) === ElementPaymentMethod.CONTAINER_ELEMENT) {
1178
+ var _data$context3;
1179
+ this.dispatchToSDK(EVENT.eventCallback.name, (_data$context3 = data.context) === null || _data$context3 === void 0 || (_data$context3 = _data$context3.data) === null || _data$context3 === void 0 ? void 0 : _data$context3.data);
1180
+ }
1181
+ }
1182
+
1171
1183
  /**
1172
1184
  * @description Processing messages from iframe
1173
1185
  */
1174
1186
  }, {
1175
1187
  key: "_handleAppMessage",
1176
1188
  value: function _handleAppMessage(data) {
1177
- var _data$context2,
1189
+ var _data$context5,
1178
1190
  _this7 = this,
1179
- _data$context3;
1191
+ _data$context6;
1180
1192
  var eventKeyMap = Object.keys(EVENT).map(function (key) {
1181
1193
  return EVENT[key].name;
1182
1194
  });
@@ -1205,11 +1217,12 @@ var ComponentApp = /*#__PURE__*/function () {
1205
1217
  return;
1206
1218
  }
1207
1219
  if (data.context.event === EVENT.popupWindow.name) {
1208
- var _data$context;
1209
- this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
1220
+ var _data$context4;
1221
+ this.createDialog((_data$context4 = data.context) === null || _data$context4 === void 0 ? void 0 : _data$context4.data);
1210
1222
  return;
1211
1223
  }
1212
1224
  if (data.context.event === EVENT.sendMuitiAppEventToSdk.name) {
1225
+ this.elementEventCallback(data);
1213
1226
  this.dispatchToApp({
1214
1227
  context: {
1215
1228
  event: 'receiveMuitiAppFromSdk',
@@ -1305,7 +1318,7 @@ var ComponentApp = /*#__PURE__*/function () {
1305
1318
  title: 'sdk_event_event_callback'
1306
1319
  }).send();
1307
1320
  }
1308
- if ((data === null || data === void 0 || (_data$context2 = data.context) === null || _data$context2 === void 0 ? void 0 : _data$context2.event) === EVENT.getGooglePayToken.name) {
1321
+ if ((data === null || data === void 0 || (_data$context5 = data.context) === null || _data$context5 === void 0 ? void 0 : _data$context5.event) === EVENT.getGooglePayToken.name) {
1309
1322
  handleGooglePay(data).then(function (res) {
1310
1323
  _this7.dispatchToApp({
1311
1324
  context: {
@@ -1337,11 +1350,11 @@ var ComponentApp = /*#__PURE__*/function () {
1337
1350
  this.dispatchToApp({
1338
1351
  context: {
1339
1352
  event: EVENT.closePaymentPolling.name,
1340
- data: {}
1353
+ data: data.context.data
1341
1354
  }
1342
1355
  });
1343
1356
  }
1344
- if ((data === null || data === void 0 || (_data$context3 = data.context) === null || _data$context3 === void 0 ? void 0 : _data$context3.event) === EVENT.getApplePayToken.name) {
1357
+ if ((data === null || data === void 0 || (_data$context6 = data.context) === null || _data$context6 === void 0 ? void 0 : _data$context6.event) === EVENT.getApplePayToken.name) {
1345
1358
  var _this$_renderParams16, _this$_renderParams17;
1346
1359
  var applePayService = new ApplePaySdk({
1347
1360
  paymentSessionData: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.sessionData,
@@ -1386,11 +1399,11 @@ var ComponentApp = /*#__PURE__*/function () {
1386
1399
  key: "logEventCallback",
1387
1400
  value: function logEventCallback(data, title) {
1388
1401
  if (data.context.event === EVENT.eventCallback.name) {
1389
- var _data$context5;
1402
+ var _data$context8;
1390
1403
  var callbackData = '';
1391
1404
  try {
1392
- var _data$context4;
1393
- callbackData = JSON.stringify((data === null || data === void 0 || (_data$context4 = data.context) === null || _data$context4 === void 0 ? void 0 : _data$context4.data) || '');
1405
+ var _data$context7;
1406
+ callbackData = JSON.stringify((data === null || data === void 0 || (_data$context7 = data.context) === null || _data$context7 === void 0 ? void 0 : _data$context7.data) || '');
1394
1407
  } catch (e) {
1395
1408
  console.error(e);
1396
1409
  }
@@ -1398,7 +1411,7 @@ var ComponentApp = /*#__PURE__*/function () {
1398
1411
  title: title
1399
1412
  }, {
1400
1413
  callbackData: callbackData,
1401
- callbackId: (data === null || data === void 0 || (_data$context5 = data.context) === null || _data$context5 === void 0 ? void 0 : _data$context5.eventCallbackId) || ''
1414
+ callbackId: (data === null || data === void 0 || (_data$context8 = data.context) === null || _data$context8 === void 0 ? void 0 : _data$context8.eventCallbackId) || ''
1402
1415
  }).send();
1403
1416
  }
1404
1417
  }
@@ -1,6 +1,5 @@
1
1
  import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
2
2
  import type { Logger } from '../util/logger';
3
- export * as elementService from './element';
4
3
  export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
5
4
  export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
6
5
  export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
@@ -16,8 +16,6 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
16
16
  */
17
17
  import { marmotConfigMap } from "../config";
18
18
  import { request } from "../request";
19
- import * as _elementService from "./element";
20
- export { _elementService as elementService };
21
19
  export function queryPaymentInfo(_x, _x2, _x3) {
22
20
  return _queryPaymentInfo.apply(this, arguments);
23
21
  }