@alipay/ams-checkout 1.31.1 → 1.34.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 (67) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/component/popupWindow.style.js +4 -1
  4. package/esm/config/index.d.ts +7 -7
  5. package/esm/config/index.js +7 -7
  6. package/esm/constant/index.d.ts +12 -0
  7. package/esm/constant/index.js +12 -0
  8. package/esm/core/component/element/elementContainerService/containerService.d.ts +33 -0
  9. package/esm/core/component/element/elementContainerService/containerService.js +123 -0
  10. package/esm/core/component/element/elementContainerService/index.d.ts +20 -0
  11. package/esm/core/component/element/elementContainerService/index.js +63 -0
  12. package/esm/core/component/element/elementController/index.d.ts +27 -0
  13. package/esm/core/component/element/elementController/index.js +478 -0
  14. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
  15. package/esm/core/component/element/elementProcessor/addressProcessor.js +160 -0
  16. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
  17. package/esm/core/component/element/elementProcessor/authProcessor.js +125 -0
  18. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +38 -0
  19. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +85 -0
  20. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +20 -0
  21. package/esm/core/component/element/elementProcessor/paymentProcessor.js +373 -0
  22. package/esm/core/component/element/index.d.ts +8 -46
  23. package/esm/core/component/element/index.js +28 -922
  24. package/esm/core/component/element/mock.d.ts +4 -0
  25. package/esm/core/component/element/mock.js +365 -1
  26. package/esm/core/component/element/type.d.ts +42 -1
  27. package/esm/core/component/element/util.d.ts +60 -0
  28. package/esm/core/component/element/util.js +451 -0
  29. package/esm/core/component/index.d.ts +5 -1
  30. package/esm/core/component/index.js +1 -2
  31. package/esm/core/component/oldElement/index.d.ts +59 -0
  32. package/esm/core/component/oldElement/index.js +956 -0
  33. package/esm/core/component/oldElement/mock.d.ts +6 -0
  34. package/esm/core/component/oldElement/mock.js +567 -0
  35. package/esm/core/component/oldElement/type.d.ts +351 -0
  36. package/esm/core/component/oldElement/type.js +81 -0
  37. package/esm/foundation/core/index.d.ts +6 -1
  38. package/esm/foundation/core/index.js +73 -35
  39. package/esm/foundation/index.d.ts +14 -0
  40. package/esm/foundation/index.js +13 -2
  41. package/esm/foundation/product-processor/easysafepay/deps.d.ts +2 -0
  42. package/esm/foundation/product-processor/easysafepay/deps.js +3 -1
  43. package/esm/foundation/product-processor/easysafepay/index.d.ts +3 -0
  44. package/esm/foundation/product-processor/easysafepay/index.js +42 -26
  45. package/esm/foundation/product-processor/element/index.d.ts +7 -0
  46. package/esm/foundation/product-processor/element/index.js +24 -0
  47. package/esm/foundation/service/container/index.d.ts +6 -3
  48. package/esm/foundation/service/container/index.js +45 -15
  49. package/esm/foundation/service/container/popup.d.ts +1 -1
  50. package/esm/foundation/service/event-center.js +1 -0
  51. package/esm/foundation/service/log/keys.js +3 -1
  52. package/esm/foundation/service/log/types.d.ts +1 -0
  53. package/esm/foundation/service/requester/requester.js +5 -4
  54. package/esm/index.js +1 -0
  55. package/esm/plugin/component/cashierApp.d.ts +1 -1
  56. package/esm/plugin/component/index.js +1 -1
  57. package/esm/types/index.d.ts +1 -1
  58. package/esm/types/index.js +1 -1
  59. package/package.json +1 -1
  60. /package/esm/core/component/{element → oldElement}/components/address.d.ts +0 -0
  61. /package/esm/core/component/{element → oldElement}/components/address.js +0 -0
  62. /package/esm/core/component/{element → oldElement}/components/auth.d.ts +0 -0
  63. /package/esm/core/component/{element → oldElement}/components/auth.js +0 -0
  64. /package/esm/core/component/{element → oldElement}/components/payment.d.ts +0 -0
  65. /package/esm/core/component/{element → oldElement}/components/payment.js +0 -0
  66. /package/esm/core/component/{element → oldElement}/utils.d.ts +0 -0
  67. /package/esm/core/component/{element → oldElement}/utils.js +0 -0
@@ -7,14 +7,16 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
7
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; }
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
- import { DisplayTypeEnum } from "../../../types";
11
- import { createIframe, startSizeChangeAnim } from "./utils";
10
+ import { isEmpty } from "../../../util";
12
11
  import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
13
12
  import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
14
- import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, LOADING_ID, MOCKUP_ID } from "../../../constant";
13
+ import { insertStyleSheet } from "../../../component/popupWindow.style";
14
+ import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, EVENT, LOADING_ID, MOCKUP_ID, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../../constant";
15
+ import { DisplayTypeEnum, ProductSceneEnum } from "../../../types";
15
16
  import { ServiceProvider } from "../index";
16
- import { EVENT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../../constant";
17
17
  import { PopupManager } from "./popup";
18
+ import { createIframe, startSizeChangeAnim } from "./utils";
19
+
18
20
  /**
19
21
  * @author 谦彧 <zhangmian.zm@alipay.com>
20
22
  * @date 2024/9/17
@@ -25,6 +27,7 @@ export var ContainerService = /*#__PURE__*/function () {
25
27
  _classCallCheck(this, ContainerService);
26
28
  _defineProperty(this, "instanceId", void 0);
27
29
  _defineProperty(this, "sdkMetaData", void 0);
30
+ _defineProperty(this, "initMessageEvent", void 0);
28
31
  _defineProperty(this, "clearTimerIdMapping", {});
29
32
  _defineProperty(this, "popupManager", void 0);
30
33
  _defineProperty(this, "eventCenter", void 0);
@@ -46,7 +49,11 @@ export var ContainerService = /*#__PURE__*/function () {
46
49
  this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
47
50
  this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
48
51
  this.popupManager = new PopupManager();
49
- this.addCapabilityToEventCenter();
52
+ // element因涉及多组件联动,消息接受处理在产品层进行
53
+ var notAddEventCenter = Boolean(Object.keys(initOptions).length) && sdkMetaData.productScene === ProductSceneEnum.ELEMENT_PAYMENT;
54
+ if (!notAddEventCenter) {
55
+ this.addCapabilityToEventCenter();
56
+ }
50
57
  this.addCapabilityToApiBusManager();
51
58
  }
52
59
  }, {
@@ -55,10 +62,21 @@ export var ContainerService = /*#__PURE__*/function () {
55
62
  }, {
56
63
  key: "load",
57
64
  value: function load(displayInfo, url, closeBtnFunc) {
58
- var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(displayInfo.selector) : ''));
65
+ var appendAliasContainerId = displayInfo.appendAliasContainerId,
66
+ selector = displayInfo.selector,
67
+ type = displayInfo.type,
68
+ platform = displayInfo.platform;
69
+ var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(selector) : ''));
70
+ if (!isEmpty(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle)) {
71
+ Object.keys(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle).forEach(function (key) {
72
+ var _displayInfo$iframeSt;
73
+ webApp.style[key] = displayInfo === null || displayInfo === void 0 || (_displayInfo$iframeSt = displayInfo.iframeStyle) === null || _displayInfo$iframeSt === void 0 ? void 0 : _displayInfo$iframeSt[key];
74
+ });
75
+ }
59
76
  this.webApp = webApp;
60
77
  this.displayInfo = displayInfo;
61
78
  webApp.src = url;
79
+ webApp.allow = 'payment';
62
80
  this.eventCenter.addIFrame(webApp);
63
81
  if (webApp.src.includes('?')) {
64
82
  this.popupManager.setPopupUrlQuery(webApp.src.split('?')[1]);
@@ -66,7 +84,7 @@ export var ContainerService = /*#__PURE__*/function () {
66
84
  // TODO call ApiBusManager to add listener to iframe, componentApp line 979
67
85
 
68
86
  // create container and append web app
69
- var container = displayInfo.type === DisplayTypeEnum.inline ? createInlineBaseElement(displayInfo.selector) : createBaseElement(displayInfo.platform, closeBtnFunc);
87
+ var container = type === DisplayTypeEnum.inline ? createInlineBaseElement(selector, appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : '') : createBaseElement(platform, closeBtnFunc);
70
88
  container.appendChild(webApp);
71
89
  return container;
72
90
  }
@@ -75,7 +93,7 @@ export var ContainerService = /*#__PURE__*/function () {
75
93
  value: function cleanContainer(displayInfo) {
76
94
  var _document$getElementB;
77
95
  // selector and container
78
- var selector = displayInfo.type === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
96
+ var selector = (displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.type) === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
79
97
  var selectorDom = document.querySelector(selector);
80
98
  if (selectorDom) {
81
99
  selectorDom.innerHTML = '';
@@ -86,7 +104,7 @@ export var ContainerService = /*#__PURE__*/function () {
86
104
  this.eventCenter.cleanIFrames();
87
105
 
88
106
  // animation
89
- (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
107
+ (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
90
108
  }
91
109
  }, {
92
110
  key: "showLoading",
@@ -158,9 +176,12 @@ export var ContainerService = /*#__PURE__*/function () {
158
176
  this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
159
177
  var _this$displayInfo2;
160
178
  if (data.paymentElementOldModel) return;
179
+ insertStyleSheet();
161
180
  _this.popupManager.popup(_objectSpread({
162
181
  platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
163
- }, data)).catch(function (error) {
182
+ }, data)).then(function () {
183
+ _this.eventCenter.addIFrame(_this.popupManager.popupApp);
184
+ }).catch(function (error) {
164
185
  _this.logService.logError({
165
186
  title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
166
187
  }, error);
@@ -207,22 +228,26 @@ export var ContainerService = /*#__PURE__*/function () {
207
228
  }, {
208
229
  key: "handleSizeChanged",
209
230
  value: function handleSizeChanged(data) {
231
+ var _this$displayInfo3 = this.displayInfo,
232
+ appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
233
+ selector = _this$displayInfo3.selector;
234
+ var cashierId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat((selector === null || selector === void 0 ? void 0 : selector.indexOf('#')) === -1 ? selector : selector.slice(1)) : COMPONENT_CONTAINER_ID;
210
235
  if (!this.webApp || !this.displayInfo) {
211
236
  return;
212
237
  }
213
- var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
214
- if ((data === null || data === void 0 ? void 0 : data.height) <= 1 || data.height === parseInt(cashier.style.height)) return;
238
+ var cashier = document.getElementById(cashierId);
239
+ if (!cashier || (data === null || data === void 0 ? void 0 : data.height) <= 1 || data.height === parseInt(cashier.style.height)) return;
215
240
  cashier.style.height = "".concat(data.height, "px");
216
241
  this.webApp.style.opacity = '1';
217
242
  if (this.displayInfo.type === DisplayTypeEnum.popup) {
218
243
  if (this.displayInfo.platform === 'desktop') {
219
244
  if (data.width) cashier.style.width = "".concat(data.width, "px");
220
- cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.displayInfo.platform, "-animation"));
245
+ cashier.classList.add("".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation"));
221
246
  this.webApp.style.height = "".concat(data.height, "px");
222
247
  }
223
248
  if (this.displayInfo.platform === 'mobile') {
224
- cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.displayInfo.platform, "-animation"));
225
- var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.displayInfo.platform, "-animation-style");
249
+ cashier.classList.add("".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation"));
250
+ var animationStyleId = "".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation-style");
226
251
  var animationStyle = document.getElementById(animationStyleId);
227
252
  if (animationStyle) animationStyle === null || animationStyle === void 0 || animationStyle.remove();
228
253
 
@@ -298,6 +323,11 @@ export var ContainerService = /*#__PURE__*/function () {
298
323
  closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-hidden"));
299
324
  }
300
325
  }
326
+ }, {
327
+ key: "getWebApp",
328
+ value: function getWebApp() {
329
+ return this.webApp;
330
+ }
301
331
  }]);
302
332
  return ContainerService;
303
333
  }();
@@ -5,7 +5,7 @@ import { PlatformEnum } from '../../../types';
5
5
  */
6
6
  export declare class PopupManager {
7
7
  private popupUrlQuery;
8
- private popupApp;
8
+ popupApp: HTMLIFrameElement;
9
9
  setPopupUrlQuery(queryParams: string): void;
10
10
  popup(data: {
11
11
  url: string;
@@ -109,6 +109,7 @@ export var EventCenter = /*#__PURE__*/function () {
109
109
  var isJson = isJsonString(e.data);
110
110
  if (isJson) {
111
111
  var _eventPayload = JSON.parse(e.data);
112
+ if (_eventPayload.context.event && _eventPayload.context.event !== 'onLog') {}
112
113
  if (!this.checkEventCompliant(_eventPayload)) {
113
114
  return;
114
115
  }
@@ -89,7 +89,9 @@ _defineProperty(LogComplianceExtendKeys, "complianceExtParams", {
89
89
  // M 数字类型
90
90
  timeCost: 'M',
91
91
  pageLoadProgress: 'M',
92
- fsDuration: 'M'
92
+ fsDuration: 'M',
93
+ // 由于部分logerror参数是msg
94
+ msg: 'C'
93
95
  });
94
96
  export var KEYS = {
95
97
  EVENT_SDK_ON_ABNORMAL_EVENT_NAME: {
@@ -5,6 +5,7 @@
5
5
  export interface LogPayload {
6
6
  title?: string;
7
7
  msg?: string;
8
+ errorMessage?: string;
8
9
  name?: string;
9
10
  label?: string;
10
11
  time?: number;
@@ -86,7 +86,7 @@ export var RequesterService = /*#__PURE__*/function () {
86
86
  time: Date.now() - startTime,
87
87
  success: false,
88
88
  code: errorCode,
89
- msg: errorMessage,
89
+ errorMessage: errorMessage,
90
90
  traceId: traceId
91
91
  });
92
92
  throw new Error(JSON.stringify({
@@ -102,7 +102,7 @@ export var RequesterService = /*#__PURE__*/function () {
102
102
  time: Date.now() - startTime,
103
103
  success: true,
104
104
  code: 'SUCCESS',
105
- msg: '',
105
+ errorMessage: '',
106
106
  traceId: traceId
107
107
  });
108
108
  return _context.abrupt("return", resData);
@@ -124,13 +124,14 @@ export var RequesterService = /*#__PURE__*/function () {
124
124
  time: Date.now() - startTime,
125
125
  success: false,
126
126
  code: _errorCode,
127
- msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
127
+ errorMessage: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.errorMessage) || _context.t0)
128
128
  });
129
129
  return _context.abrupt("return", Promise.reject({
130
130
  success: false,
131
131
  errorCode: _errorCode,
132
132
  traceId: traceId,
133
- errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
133
+ stack: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.stack,
134
+ errorMessage: _error === null || _error === void 0 ? void 0 : _error.errorMessage
134
135
  }));
135
136
  case 31:
136
137
  case "end":
package/esm/index.js CHANGED
@@ -27,6 +27,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
27
27
  import { ADDRESSElementAppVersion, AMSAutoDebitAppVersion, AMSCashierPaymentAppVersion, AMSCheckoutAppVersion, AMSPaymentElementAppVersion, AMSVaultingAppVersion } from "./config/index";
28
28
  import { AddressComponent } from "./core/component/address";
29
29
  import { ElementComponent } from "./core/component/element";
30
+ // import { ElementComponent } from './core/component/oldElement';
30
31
  import { AMSComponent } from "./core/component/index";
31
32
  import { ComponentSignEnum, DisplayTypeEnum, PaymentMethodCategoryTypeEnum } from "./types";
32
33
  import { ProductSceneEnum } from "./types/index";
@@ -1,4 +1,4 @@
1
- import { ComponentSignEnum, Ianalytics, DisplayTypeEnum } from '../../types';
1
+ import { ComponentSignEnum, DisplayTypeEnum, Ianalytics } from '../../types';
2
2
  export declare const getAppPath: (environment: string, appVersion: string, componentSign: ComponentSignEnum, productScene: string, productSceneVersion: string, extendInfo: string, mid: string, sendLog?: boolean, elementLink?: string) => any;
3
3
  export declare const getAppDomain: (domainParams: {
4
4
  environment: string;
@@ -20,10 +20,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
20
20
  import { v4 as uuid } from 'uuid';
21
21
  import { sdkVersion } from "../../config";
22
22
  import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
23
+ import { ElementPaymentMethod } from "../../core/component/oldElement/type";
23
24
  import { queryPaymentInfo, submitPayInfo } from "../../service";
24
25
  import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
25
26
  import { getType, isJsonString, isPC } from "../../util";
26
- import { ElementPaymentMethod } from "../../core/component/element/type";
27
27
  import { getBackScheme } from "../../util/getBackScheme";
28
28
  import { isLocalMock } from "../../util/mock";
29
29
  import { matchVersion } from "../../util/versionCompare";
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { IApplePayContactField } from '../plugin/applepay/interface';
9
9
  export type onChange = () => onCnageResult;
10
- export { type IElementOptions, ElementType, ThemeType, PaymentElementLayout } from '../core/component/element/type';
10
+ export { type IElementOptions, ElementType, ThemeType, PaymentElementLayout } from '../core/component/oldElement/type';
11
11
  interface onCnageResult {
12
12
  complete: boolean;
13
13
  addressValue: AddressItem[];
@@ -8,7 +8,7 @@
8
8
 
9
9
  /* eslint-disable @typescript-eslint/no-explicit-any */
10
10
 
11
- export { ElementType, ThemeType, PaymentElementLayout } from "../core/component/element/type";
11
+ export { ElementType, ThemeType, PaymentElementLayout } from "../core/component/oldElement/type";
12
12
 
13
13
  /**
14
14
  * SDK options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "1.31.1",
3
+ "version": "1.34.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",