@alipay/ams-checkout 0.0.1755258862-dev.0 → 0.0.1755681537-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.
Files changed (99) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +3 -1
  3. package/esm/component/channel.js +26 -62
  4. package/esm/component/component.inline.style.js +2 -2
  5. package/esm/component/popupWindow.style.d.ts +4 -1
  6. package/esm/component/popupWindow.style.js +37 -2
  7. package/esm/config/index.d.ts +8 -8
  8. package/esm/config/index.js +8 -8
  9. package/esm/constant/easysafepay.d.ts +16 -0
  10. package/esm/constant/easysafepay.js +19 -0
  11. package/esm/constant/index.d.ts +41 -2
  12. package/esm/constant/index.js +43 -5
  13. package/esm/core/component/ckp/index.d.ts +2 -0
  14. package/esm/core/component/ckp/index.js +41 -5
  15. package/esm/core/component/element/elementContainerService/containerService.d.ts +33 -0
  16. package/esm/core/component/element/elementContainerService/containerService.js +123 -0
  17. package/esm/core/component/element/elementContainerService/index.d.ts +20 -0
  18. package/esm/core/component/element/elementContainerService/index.js +63 -0
  19. package/esm/core/component/element/elementController/index.d.ts +27 -0
  20. package/esm/core/component/element/elementController/index.js +493 -0
  21. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
  22. package/esm/core/component/element/elementProcessor/addressProcessor.js +160 -0
  23. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
  24. package/esm/core/component/element/elementProcessor/authProcessor.js +125 -0
  25. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +41 -0
  26. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +96 -0
  27. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +20 -0
  28. package/esm/core/component/element/elementProcessor/paymentProcessor.js +380 -0
  29. package/esm/core/component/element/index.d.ts +7 -46
  30. package/esm/core/component/element/index.js +31 -923
  31. package/esm/core/component/element/mock.d.ts +4 -0
  32. package/esm/core/component/element/mock.js +365 -1
  33. package/esm/core/component/element/type.d.ts +74 -34
  34. package/esm/core/component/element/type.js +20 -12
  35. package/esm/core/component/element/util.d.ts +69 -0
  36. package/esm/core/component/element/util.js +477 -0
  37. package/esm/core/component/index.d.ts +5 -1
  38. package/esm/core/component/index.js +1 -2
  39. package/esm/core/component/oldElement/index.d.ts +59 -0
  40. package/esm/core/component/oldElement/index.js +956 -0
  41. package/esm/core/component/oldElement/mock.d.ts +6 -0
  42. package/esm/core/component/oldElement/mock.js +567 -0
  43. package/esm/core/component/oldElement/type.d.ts +354 -0
  44. package/esm/core/component/oldElement/type.js +81 -0
  45. package/esm/core/instance/index.d.ts +1 -1
  46. package/esm/core/instance/index.js +1 -1
  47. package/esm/foundation/core/index.d.ts +9 -1
  48. package/esm/foundation/core/index.js +153 -49
  49. package/esm/foundation/index.d.ts +20 -0
  50. package/esm/foundation/index.js +13 -2
  51. package/esm/foundation/product-processor/autoDebit/deps.d.ts +14 -0
  52. package/esm/foundation/product-processor/autoDebit/deps.js +12 -0
  53. package/esm/foundation/product-processor/autoDebit/index.d.ts +48 -0
  54. package/esm/foundation/product-processor/autoDebit/index.js +466 -0
  55. package/esm/foundation/product-processor/easysafepay/deps.d.ts +3 -1
  56. package/esm/foundation/product-processor/easysafepay/deps.js +3 -1
  57. package/esm/foundation/product-processor/easysafepay/index.d.ts +5 -0
  58. package/esm/foundation/product-processor/easysafepay/index.js +266 -138
  59. package/esm/foundation/product-processor/element/index.d.ts +7 -0
  60. package/esm/foundation/product-processor/element/index.js +24 -0
  61. package/esm/foundation/service/container/index.d.ts +14 -3
  62. package/esm/foundation/service/container/index.js +178 -25
  63. package/esm/foundation/service/container/popup.d.ts +10 -7
  64. package/esm/foundation/service/container/popup.js +3 -1
  65. package/esm/foundation/service/event-center.js +1 -0
  66. package/esm/foundation/service/log/keys.js +3 -1
  67. package/esm/foundation/service/log/types.d.ts +1 -0
  68. package/esm/foundation/service/requester/requester.js +17 -37
  69. package/esm/foundation/utils/preload_helper.d.ts +2 -2
  70. package/esm/foundation/utils/preload_helper.js +8 -4
  71. package/esm/foundation/utils/redirect_utils.js +34 -18
  72. package/esm/foundation/utils/web_app_url_utils.d.ts +71 -1
  73. package/esm/foundation/utils/web_app_url_utils.js +219 -8
  74. package/esm/index.d.ts +8 -5
  75. package/esm/index.js +103 -53
  76. package/esm/plugin/component/cashierApp.d.ts +1 -1
  77. package/esm/plugin/component/cashierApp.js +5 -5
  78. package/esm/plugin/component/channel.d.ts +3 -1
  79. package/esm/plugin/component/channel.js +10 -12
  80. package/esm/plugin/component/index.js +47 -44
  81. package/esm/plugin/type.d.ts +1 -1
  82. package/esm/request/index.js +2 -2
  83. package/esm/types/index.d.ts +37 -3
  84. package/esm/types/index.js +10 -2
  85. package/esm/util/index.d.ts +12 -1
  86. package/esm/util/index.js +39 -3
  87. package/esm/util/redirect.d.ts +6 -0
  88. package/esm/util/redirect.js +54 -0
  89. package/esm/util/spm-map.d.ts +18 -4
  90. package/esm/util/spm-map.js +20 -6
  91. package/package.json +27 -4
  92. /package/esm/core/component/{element → oldElement}/components/address.d.ts +0 -0
  93. /package/esm/core/component/{element → oldElement}/components/address.js +0 -0
  94. /package/esm/core/component/{element → oldElement}/components/auth.d.ts +0 -0
  95. /package/esm/core/component/{element → oldElement}/components/auth.js +0 -0
  96. /package/esm/core/component/{element → oldElement}/components/payment.d.ts +0 -0
  97. /package/esm/core/component/{element → oldElement}/components/payment.js +0 -0
  98. /package/esm/core/component/{element → oldElement}/utils.d.ts +0 -0
  99. /package/esm/core/component/{element → oldElement}/utils.js +0 -0
@@ -0,0 +1,24 @@
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 _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ var ElementProcessor = /*#__PURE__*/function () {
8
+ function ElementProcessor() {
9
+ _classCallCheck(this, ElementProcessor);
10
+ }
11
+ _createClass(ElementProcessor, [{
12
+ key: "init",
13
+ value: function init(config, instanceId) {
14
+ return null;
15
+ }
16
+ }, {
17
+ key: "startBizFlow",
18
+ value: function startBizFlow() {
19
+ return null;
20
+ }
21
+ }]);
22
+ return ElementProcessor;
23
+ }();
24
+ export { ElementProcessor };
@@ -1,30 +1,41 @@
1
- import { DisplayInfo, SDKMetaData, Service } from '../../index';
2
1
  import { IoptionsParams } from '../../../types';
2
+ import { DisplayInfo, SDKMetaData, Service } from '../../index';
3
+ import { PopupManager } from './popup';
3
4
  export declare class ContainerService implements Service {
4
5
  private instanceId;
5
6
  private sdkMetaData;
7
+ private initMessageEvent;
6
8
  private clearTimerIdMapping;
7
- private popupManager;
9
+ popupManager: PopupManager;
8
10
  private eventCenter;
9
11
  private logService;
10
12
  private displayInfo;
11
13
  private webApp;
12
14
  private _webAppHeartBeatTimeoutFn;
15
+ private clientHeight;
16
+ private boundFocusResizeChange;
13
17
  private customizedLoadingListener;
14
18
  destroy(): void;
15
19
  init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
16
20
  update(): void;
17
- load(displayInfo: DisplayInfo, url: string, closeBtnFunc: () => void): HTMLDivElement;
21
+ load(displayInfo: DisplayInfo, url: string, closeBtnFunc?: () => void): HTMLDivElement;
18
22
  cleanContainer(displayInfo: DisplayInfo): void;
19
23
  showLoading(container: HTMLDivElement, displayInfo: DisplayInfo): void;
20
24
  dismissLoading(isKeepMockup?: boolean): void;
21
25
  customizeLoading(listener: (event: 'SDK_START_OF_LOADING' | 'SDK_END_OF_LOADING') => void): void;
22
26
  startHideAnim(): void;
27
+ private handleAccountFocus;
23
28
  private addCapabilityToEventCenter;
24
29
  private addCapabilityToApiBusManager;
25
30
  private updateMaskCloseBtn;
26
31
  private handleSizeChanged;
32
+ private focusResizeChange;
33
+ private focusScrollFixed;
27
34
  private handleAppHeartBeat;
28
35
  private changeCloseBtnVisibility;
29
36
  private handleMaskCloseBtnShow;
37
+ private handleCloseButtonTheme;
38
+ private handlePopupWindow;
39
+ private handlePopWindow;
40
+ getWebApp(): HTMLIFrameElement;
30
41
  }
@@ -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, closeImg, closeImgLight } 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);
@@ -32,6 +35,8 @@ export var ContainerService = /*#__PURE__*/function () {
32
35
  _defineProperty(this, "displayInfo", void 0);
33
36
  _defineProperty(this, "webApp", void 0);
34
37
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
38
+ _defineProperty(this, "clientHeight", void 0);
39
+ _defineProperty(this, "boundFocusResizeChange", void 0);
35
40
  // if this variable is true, SDK will invoke listener instead of showing loading
36
41
  _defineProperty(this, "customizedLoadingListener", void 0);
37
42
  }
@@ -41,13 +46,21 @@ export var ContainerService = /*#__PURE__*/function () {
41
46
  }, {
42
47
  key: "init",
43
48
  value: function init(initOptions, instanceId, sdkMetaData) {
49
+ var _window;
44
50
  this.instanceId = instanceId;
45
51
  this.sdkMetaData = sdkMetaData;
52
+ this.clientHeight = Math.max(window.innerHeight, ((_window = window) === null || _window === void 0 || (_window = _window.visualViewport) === null || _window === void 0 ? void 0 : _window.height) || 0);
46
53
  this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
47
54
  this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
48
55
  this.popupManager = new PopupManager();
49
- this.addCapabilityToEventCenter();
56
+ // element因涉及多组件联动,消息接受处理在产品层进行
57
+ var notAddEventCenter = Boolean(Object.keys(initOptions).length) && sdkMetaData.productScene === ProductSceneEnum.ELEMENT_PAYMENT;
58
+ if (!notAddEventCenter) {
59
+ this.addCapabilityToEventCenter();
60
+ }
50
61
  this.addCapabilityToApiBusManager();
62
+ // bind会返回一个新的方法,init时记录上这个focus,不然window.addEventListener时this指向会变成window
63
+ this.boundFocusResizeChange = this.focusResizeChange.bind(this);
51
64
  }
52
65
  }, {
53
66
  key: "update",
@@ -55,10 +68,21 @@ export var ContainerService = /*#__PURE__*/function () {
55
68
  }, {
56
69
  key: "load",
57
70
  value: function load(displayInfo, url, closeBtnFunc) {
58
- var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(displayInfo.selector) : ''));
71
+ var appendAliasContainerId = displayInfo.appendAliasContainerId,
72
+ selector = displayInfo.selector,
73
+ type = displayInfo.type,
74
+ platform = displayInfo.platform;
75
+ var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(selector) : ''));
76
+ if (!isEmpty(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle)) {
77
+ Object.keys(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle).forEach(function (key) {
78
+ var _displayInfo$iframeSt;
79
+ webApp.style[key] = displayInfo === null || displayInfo === void 0 || (_displayInfo$iframeSt = displayInfo.iframeStyle) === null || _displayInfo$iframeSt === void 0 ? void 0 : _displayInfo$iframeSt[key];
80
+ });
81
+ }
59
82
  this.webApp = webApp;
60
83
  this.displayInfo = displayInfo;
61
84
  webApp.src = url;
85
+ webApp.allow = 'payment';
62
86
  this.eventCenter.addIFrame(webApp);
63
87
  if (webApp.src.includes('?')) {
64
88
  this.popupManager.setPopupUrlQuery(webApp.src.split('?')[1]);
@@ -66,7 +90,7 @@ export var ContainerService = /*#__PURE__*/function () {
66
90
  // TODO call ApiBusManager to add listener to iframe, componentApp line 979
67
91
 
68
92
  // create container and append web app
69
- var container = displayInfo.type === DisplayTypeEnum.inline ? createInlineBaseElement(displayInfo.selector) : createBaseElement(displayInfo.platform, closeBtnFunc);
93
+ 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
94
  container.appendChild(webApp);
71
95
  return container;
72
96
  }
@@ -75,7 +99,7 @@ export var ContainerService = /*#__PURE__*/function () {
75
99
  value: function cleanContainer(displayInfo) {
76
100
  var _document$getElementB;
77
101
  // selector and container
78
- var selector = displayInfo.type === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
102
+ var selector = (displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.type) === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
79
103
  var selectorDom = document.querySelector(selector);
80
104
  if (selectorDom) {
81
105
  selectorDom.innerHTML = '';
@@ -86,7 +110,7 @@ export var ContainerService = /*#__PURE__*/function () {
86
110
  this.eventCenter.cleanIFrames();
87
111
 
88
112
  // animation
89
- (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
113
+ (_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
114
  }
91
115
  }, {
92
116
  key: "showLoading",
@@ -138,6 +162,22 @@ export var ContainerService = /*#__PURE__*/function () {
138
162
  container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.displayInfo.platform));
139
163
  }
140
164
  }
165
+ }, {
166
+ key: "handleAccountFocus",
167
+ value: function handleAccountFocus(focus) {
168
+ var _window$visualViewpor, _window2;
169
+ // 失焦时v2会走默认的sizeChange还原高度,这里仅移除监听
170
+ (_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.boundFocusResizeChange);
171
+ (_window2 = window) === null || _window2 === void 0 || _window2.removeEventListener('resize', this.boundFocusResizeChange);
172
+ // 只有聚焦才监听,失焦后移除,避免影响别的场景
173
+ if (focus) {
174
+ var _window$visualViewpor2;
175
+ // 监听页面visualViewport的高度变化,适用于主流机型更精准获取当前页面高度
176
+ (_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.addEventListener('resize', this.boundFocusResizeChange);
177
+ // 兼容visualViewport处理不到的场景,一般存在于老版本浏览器
178
+ window.addEventListener('resize', this.boundFocusResizeChange);
179
+ }
180
+ }
141
181
  }, {
142
182
  key: "addCapabilityToEventCenter",
143
183
  value: function addCapabilityToEventCenter() {
@@ -156,16 +196,7 @@ export var ContainerService = /*#__PURE__*/function () {
156
196
  });
157
197
  });
158
198
  this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
159
- var _this$displayInfo2;
160
- if (data.paymentElementOldModel) return;
161
- _this.popupManager.popup(_objectSpread({
162
- platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
163
- }, data)).catch(function (error) {
164
- _this.logService.logError({
165
- title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
166
- }, error);
167
- _this.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
168
- });
199
+ _this.handlePopupWindow(data);
169
200
  });
170
201
  this.eventCenter.listen(EVENT.popWindow.name, function () {
171
202
  _this.popupManager.pop();
@@ -173,7 +204,8 @@ export var ContainerService = /*#__PURE__*/function () {
173
204
  this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
174
205
  _this.handleSizeChanged(_objectSpread({}, data));
175
206
  });
176
- this.eventCenter.listen(EVENT.showCloseButton.name, function () {
207
+ this.eventCenter.listen(EVENT.showCloseButton.name, function (data) {
208
+ _this.handleCloseButtonTheme(data.style);
177
209
  _this.changeCloseBtnVisibility(true);
178
210
  });
179
211
  this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
@@ -185,6 +217,22 @@ export var ContainerService = /*#__PURE__*/function () {
185
217
  this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
186
218
  _this.handleAppHeartBeat();
187
219
  });
220
+ /**
221
+ * 目前仅用于ESP V2的 web sdk
222
+ * 原因: 在账户输入页和OTP页面的h5场景下键盘弹起页面会有问题,iframe有固定高度,键盘弹起时应用层不会触发大小变化
223
+ * account账号输入页需要在sdk监听键盘弹起后高度变化并修改iframe及iframe外层容器,account需要按钮置底的放在键盘上面,必须修改高度而不是让容器定位
224
+ * otp页面需要在聚焦时给iframe及外层容器设置fixed定位,让页面不被弹起
225
+ * 目的: esp页面输入框聚焦/失焦后给sdk发送消息
226
+ */
227
+ this.eventCenter.listen(EVENT.inputFocus.name, function (data) {
228
+ // 账号输入页需要修改iframe高度
229
+ if (data.source === 'ESP_V2' && data.type === 'account') {
230
+ _this.handleAccountFocus(data.focus);
231
+ // otp页面需要定位元素
232
+ } else if (data.source === 'ESP_V2' && data.type === 'otp') {
233
+ _this.focusScrollFixed(data.focus);
234
+ }
235
+ });
188
236
  }
189
237
  }, {
190
238
  key: "addCapabilityToApiBusManager",
@@ -207,22 +255,26 @@ export var ContainerService = /*#__PURE__*/function () {
207
255
  }, {
208
256
  key: "handleSizeChanged",
209
257
  value: function handleSizeChanged(data) {
258
+ var _this$displayInfo2 = this.displayInfo,
259
+ appendAliasContainerId = _this$displayInfo2.appendAliasContainerId,
260
+ selector = _this$displayInfo2.selector;
261
+ 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
262
  if (!this.webApp || !this.displayInfo) {
211
263
  return;
212
264
  }
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;
265
+ var cashier = document.getElementById(cashierId);
266
+ if (!cashier || (data === null || data === void 0 ? void 0 : data.height) <= 1 || data.height === parseInt(cashier.style.height)) return;
215
267
  cashier.style.height = "".concat(data.height, "px");
216
268
  this.webApp.style.opacity = '1';
217
269
  if (this.displayInfo.type === DisplayTypeEnum.popup) {
218
270
  if (this.displayInfo.platform === 'desktop') {
219
271
  if (data.width) cashier.style.width = "".concat(data.width, "px");
220
- cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.displayInfo.platform, "-animation"));
272
+ cashier.classList.add("".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation"));
221
273
  this.webApp.style.height = "".concat(data.height, "px");
222
274
  }
223
275
  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");
276
+ cashier.classList.add("".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation"));
277
+ var animationStyleId = "".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation-style");
226
278
  var animationStyle = document.getElementById(animationStyleId);
227
279
  if (animationStyle) animationStyle === null || animationStyle === void 0 || animationStyle.remove();
228
280
 
@@ -241,6 +293,50 @@ export var ContainerService = /*#__PURE__*/function () {
241
293
  this.webApp.style.height = "".concat(data.height, "px");
242
294
  }
243
295
  }
296
+
297
+ // 目前仅用于esp账号输入页聚焦
298
+ }, {
299
+ key: "focusResizeChange",
300
+ value: function focusResizeChange() {
301
+ var _window3;
302
+ // 计算出当前iframe应有的高度,需要和顶部留有距离
303
+ var webPageHeightRatio = 0.9;
304
+ var browserPageHeightFocusRatio = 0.9;
305
+ // sdk层才能拿到当前键盘弹起后页面的高度
306
+ var height = ((_window3 = window) === null || _window3 === void 0 || (_window3 = _window3.visualViewport) === null || _window3 === void 0 ? void 0 : _window3.height) || window.innerHeight;
307
+ height = height * webPageHeightRatio;
308
+ height = height * browserPageHeightFocusRatio;
309
+ // 调用handleSizeChanged修改iframe高度
310
+ this.handleSizeChanged({
311
+ width: 0,
312
+ height: height
313
+ });
314
+ }
315
+
316
+ // 目前仅用于esp otp页面账号聚焦
317
+ }, {
318
+ key: "focusScrollFixed",
319
+ value: function focusScrollFixed(focus) {
320
+ // 获取iframe dom元素
321
+ var _this$displayInfo3 = this.displayInfo,
322
+ appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
323
+ selector = _this$displayInfo3.selector;
324
+ 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;
325
+ if (!this.webApp || !this.displayInfo) {
326
+ return;
327
+ }
328
+ var cashier = document.getElementById(cashierId);
329
+ if (!cashier) return;
330
+ // 输入框聚焦时修改定位信息和top距离
331
+ if (focus) {
332
+ cashier.style.setProperty('position', 'fixed', 'important');
333
+ cashier.style.setProperty('top', "".concat(this.clientHeight - cashier.clientHeight, "px"), 'important');
334
+ } else {
335
+ // 失焦时移除定位信息
336
+ cashier.style.removeProperty('position');
337
+ cashier.style.removeProperty('top');
338
+ }
339
+ }
244
340
  }, {
245
341
  key: "handleAppHeartBeat",
246
342
  value: function handleAppHeartBeat() {
@@ -298,6 +394,63 @@ export var ContainerService = /*#__PURE__*/function () {
298
394
  closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-hidden"));
299
395
  }
300
396
  }
397
+ }, {
398
+ key: "handleCloseButtonTheme",
399
+ value: function handleCloseButtonTheme(style) {
400
+ if (!style) return;
401
+ var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
402
+ var closeButtonImg = closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.querySelector('img');
403
+ var maskCloseBlock = document.getElementById(COMPONENT_CLOSE_MASK_BLOCK_ID);
404
+ if (style === 'light') {
405
+ closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImgLight);
406
+ closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
407
+ maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
408
+ } else {
409
+ closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImg);
410
+ closeBlock === null || closeBlock === void 0 || closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
411
+ maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
412
+ }
413
+ }
414
+
415
+ // SDK主动打开弹框
416
+ }, {
417
+ key: "handlePopupWindow",
418
+ value: function handlePopupWindow(data) {
419
+ var _this$displayInfo4,
420
+ _this3 = this;
421
+ if (data.paymentElementOldModel) return;
422
+ insertStyleSheet();
423
+ this.popupManager.popup(_objectSpread({
424
+ platform: (_this$displayInfo4 = this.displayInfo) === null || _this$displayInfo4 === void 0 ? void 0 : _this$displayInfo4.platform,
425
+ showCloseOnLoading: data.showCloseOnLoading,
426
+ onCloseOnLoading: function onCloseOnLoading() {
427
+ return _this3.handlePopWindow(data);
428
+ }
429
+ }, data)).then(function () {
430
+ _this3.eventCenter.addIFrame(_this3.popupManager.popupApp);
431
+ }).catch(function (error) {
432
+ _this3.logService.logError({
433
+ title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
434
+ }, error);
435
+ _this3.eventCenter.emit(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
436
+ });
437
+ }
438
+
439
+ // SDK主动关闭弹框
440
+ }, {
441
+ key: "handlePopWindow",
442
+ value: function handlePopWindow(data) {
443
+ this.popupManager.pop();
444
+ this.eventCenter.dispatchToApp({
445
+ event: EVENT.popWindow.name,
446
+ data: data
447
+ });
448
+ }
449
+ }, {
450
+ key: "getWebApp",
451
+ value: function getWebApp() {
452
+ return this.webApp;
453
+ }
301
454
  }]);
302
455
  return ContainerService;
303
456
  }();
@@ -1,17 +1,20 @@
1
1
  import { PlatformEnum } from '../../../types';
2
+ export type IPopUpParams = {
3
+ url: string;
4
+ widthPadding: number;
5
+ heightPadding: number;
6
+ platform: PlatformEnum;
7
+ showCloseOnLoading: boolean;
8
+ onCloseOnLoading: () => void;
9
+ };
2
10
  /**
3
11
  * @author 谦彧 <zhangmian.zm@alipay.com>
4
12
  * @date 2024/9/22
5
13
  */
6
14
  export declare class PopupManager {
7
15
  private popupUrlQuery;
8
- private popupApp;
16
+ popupApp: HTMLIFrameElement;
9
17
  setPopupUrlQuery(queryParams: string): void;
10
- popup(data: {
11
- url: string;
12
- widthPadding: number;
13
- heightPadding: number;
14
- platform: PlatformEnum;
15
- }): Promise<void>;
18
+ popup(data: IPopUpParams): Promise<void>;
16
19
  pop(): void;
17
20
  }
@@ -53,7 +53,9 @@ export var PopupManager = /*#__PURE__*/function () {
53
53
  widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
54
54
  device: data === null || data === void 0 ? void 0 : data.platform,
55
55
  url: pageUrl,
56
- loadingConfig: undefined
56
+ loadingConfig: undefined,
57
+ showCloseOnLoading: data.showCloseOnLoading,
58
+ onCloseOnLoading: data.onCloseOnLoading
57
59
  });
58
60
  case 11:
59
61
  this.popupApp = _context.sent;
@@ -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;
@@ -13,7 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
13
13
  import axios from 'axios';
14
14
  import { ServiceProvider } from '..';
15
15
  import { errorEnum } from "./deps";
16
- import { appId, device, fomatGetwayError, get, hostSignMap, isPC, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
16
+ import { appId, device, fomatGetwayError, get, hostSignMap, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
17
17
 
18
18
  /**
19
19
  * @author congle.zzq <congle.zzq@alipay.com>
@@ -50,7 +50,6 @@ export var RequesterService = /*#__PURE__*/function () {
50
50
  return _regeneratorRuntime().wrap(function _callee$(_context) {
51
51
  while (1) switch (_context.prev = _context.next) {
52
52
  case 0:
53
- console.log('[DEBUG] request start', requestData, options);
54
53
  envInfo = this.getEnvInfo(options);
55
54
  _data = [_objectSpread(_objectSpread({}, requestData), {}, {
56
55
  envInfo: envInfo,
@@ -60,31 +59,24 @@ export var RequesterService = /*#__PURE__*/function () {
60
59
  })];
61
60
  startTime = Date.now();
62
61
  traceId = '';
63
- _context.prev = 5;
64
- console.log('[DEBUG] createRequestInstance start');
62
+ _context.prev = 4;
65
63
  myRequest = this.createRequestInstance(options);
66
- console.log('[DEBUG] createRequestInstance completed', myRequest);
67
- console.log('[DEBUG] myRequest start');
68
- _context.next = 12;
64
+ _context.next = 8;
69
65
  return myRequest({
70
66
  data: _data
71
67
  });
72
- case 12:
68
+ case 8:
73
69
  _yield$myRequest = _context.sent;
74
70
  data = _yield$myRequest.data;
75
71
  headers = _yield$myRequest.headers;
76
- console.log('[DEBUG] myRequest completed', data, headers);
77
72
  resData = data || {};
78
73
  traceId = get(headers, 'Mgw-TraceId') || get(headers, 'mgw-traceid', '');
79
74
  resData.traceId = traceId || '';
80
- console.log('[DEBUG] handleGetWayError start');
81
75
  handleGetWayError = fomatGetwayError(headers, traceId);
82
- console.log('[DEBUG] handleGetWayError completed', handleGetWayError);
83
76
  if (!(handleGetWayError !== null && handleGetWayError !== void 0 && handleGetWayError.errorCode)) {
84
- _context.next = 29;
77
+ _context.next = 20;
85
78
  break;
86
79
  }
87
- console.log('[DEBUG] handleGetWayError errorCode', handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode);
88
80
  errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
89
81
  errorCode = handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode;
90
82
  this.reportRequestTimeCost({
@@ -94,20 +86,15 @@ export var RequesterService = /*#__PURE__*/function () {
94
86
  time: Date.now() - startTime,
95
87
  success: false,
96
88
  code: errorCode,
97
- msg: errorMessage,
98
- traceId: traceId
99
- });
100
- console.log('[DEBUG] handleGetWayError error', {
101
89
  errorMessage: errorMessage,
102
- errorCode: errorCode,
103
- success: false
90
+ traceId: traceId
104
91
  });
105
92
  throw new Error(JSON.stringify({
106
93
  errorMessage: errorMessage,
107
94
  errorCode: errorCode,
108
95
  success: false
109
96
  }));
110
- case 29:
97
+ case 20:
111
98
  this.reportRequestTimeCost({
112
99
  title: 'a3753.b101271.c388193.d521387',
113
100
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
@@ -115,21 +102,19 @@ export var RequesterService = /*#__PURE__*/function () {
115
102
  time: Date.now() - startTime,
116
103
  success: true,
117
104
  code: 'SUCCESS',
118
- msg: '',
105
+ errorMessage: '',
119
106
  traceId: traceId
120
107
  });
121
- console.log('[DEBUG] request completed', resData);
122
108
  return _context.abrupt("return", resData);
123
- case 34:
124
- _context.prev = 34;
125
- _context.t0 = _context["catch"](5);
109
+ case 24:
110
+ _context.prev = 24;
111
+ _context.t0 = _context["catch"](4);
126
112
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
127
113
  success: false,
128
114
  errorCode: errorEnum.SYSTEM,
129
115
  traceId: traceId,
130
116
  errorMessage: _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message
131
117
  });
132
- console.log('[DEBUG] request error 1', _error);
133
118
  timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
134
119
  _errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
135
120
  this.reportRequestTimeCost({
@@ -139,25 +124,20 @@ export var RequesterService = /*#__PURE__*/function () {
139
124
  time: Date.now() - startTime,
140
125
  success: false,
141
126
  code: _errorCode,
142
- msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
143
- });
144
- console.log('[DEBUG] request error 2', {
145
- success: false,
146
- errorCode: _errorCode,
147
- traceId: traceId,
148
- errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
127
+ errorMessage: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.errorMessage) || _context.t0)
149
128
  });
150
129
  return _context.abrupt("return", Promise.reject({
151
130
  success: false,
152
131
  errorCode: _errorCode,
153
132
  traceId: traceId,
154
- 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
155
135
  }));
156
- case 43:
136
+ case 31:
157
137
  case "end":
158
138
  return _context.stop();
159
139
  }
160
- }, _callee, this, [[5, 34]]);
140
+ }, _callee, this, [[4, 24]]);
161
141
  }));
162
142
  function request(_x, _x2) {
163
143
  return _request.apply(this, arguments);
@@ -169,7 +149,7 @@ export var RequesterService = /*#__PURE__*/function () {
169
149
  value: function getEnvInfo(options) {
170
150
  var _options$envInfo;
171
151
  var envInfo = _objectSpread(_objectSpread({
172
- terminalType: isPC() ? 'WEB' : 'WAP',
152
+ terminalType: device.isMobile ? 'WAP' : 'WEB',
173
153
  browserInfo: {
174
154
  browserJavaScriptEnabled: true,
175
155
  browserLanguage: navigator.language,
@@ -4,10 +4,10 @@ export default class PreloadHelper {
4
4
  static isWebAppPreloaded: boolean;
5
5
  static isSecuritySDKPreloaded: boolean;
6
6
  private static securitySdkMap;
7
- static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): void;
7
+ static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string, useV2?: boolean): void;
8
8
  static preloadSecuritySDK(product: ProductSceneEnum, securityRegion?: string): void;
9
9
  static getSecuritySdk(scene: any): Security;
10
- static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string): {
10
+ static buildWebAppPreloadUrl(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment: string, useV2?: boolean): {
11
11
  preloadUrl: string;
12
12
  containerId: string;
13
13
  };