@alipay/ams-checkout 0.0.1742280578-dev.1 → 0.0.1742285920-dev.1
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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +3 -1
- package/esm/component/channel.js +26 -62
- package/esm/component/component.inline.style.js +2 -2
- package/esm/component/popupWindow.style.js +4 -1
- package/esm/config/index.d.ts +8 -8
- package/esm/config/index.js +8 -8
- package/esm/constant/easysafepay.d.ts +16 -0
- package/esm/constant/easysafepay.js +19 -0
- package/esm/constant/index.d.ts +34 -2
- package/esm/constant/index.js +36 -5
- package/esm/core/component/ckp/index.d.ts +2 -0
- package/esm/core/component/ckp/index.js +39 -5
- package/esm/core/component/element/elementContainerService/containerService.d.ts +33 -0
- package/esm/core/component/element/elementContainerService/containerService.js +123 -0
- package/esm/core/component/element/elementContainerService/index.d.ts +20 -0
- package/esm/core/component/element/elementContainerService/index.js +63 -0
- package/esm/core/component/element/elementController/index.d.ts +27 -0
- package/esm/core/component/element/elementController/index.js +485 -0
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +20 -0
- package/esm/core/component/element/elementProcessor/addressProcessor.js +160 -0
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +20 -0
- package/esm/core/component/element/elementProcessor/authProcessor.js +125 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +41 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +96 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +20 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +380 -0
- package/esm/core/component/element/index.d.ts +7 -46
- package/esm/core/component/element/index.js +31 -923
- package/esm/core/component/element/mock.d.ts +4 -0
- package/esm/core/component/element/mock.js +365 -1
- package/esm/core/component/element/type.d.ts +45 -19
- package/esm/core/component/element/util.d.ts +69 -0
- package/esm/core/component/element/util.js +477 -0
- package/esm/core/component/index.d.ts +5 -1
- package/esm/core/component/index.js +1 -2
- package/esm/core/component/oldElement/index.d.ts +59 -0
- package/esm/core/component/oldElement/index.js +956 -0
- package/esm/core/component/oldElement/mock.d.ts +6 -0
- package/esm/core/component/oldElement/mock.js +567 -0
- package/esm/core/component/oldElement/type.d.ts +354 -0
- package/esm/core/component/oldElement/type.js +81 -0
- package/esm/core/instance/index.d.ts +1 -1
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/core/index.d.ts +9 -1
- package/esm/foundation/core/index.js +153 -49
- package/esm/foundation/index.d.ts +20 -0
- package/esm/foundation/index.js +13 -2
- package/esm/foundation/product-processor/autoDebit/deps.d.ts +14 -0
- package/esm/foundation/product-processor/autoDebit/deps.js +12 -0
- package/esm/foundation/product-processor/autoDebit/index.d.ts +48 -0
- package/esm/foundation/product-processor/autoDebit/index.js +466 -0
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +3 -1
- package/esm/foundation/product-processor/easysafepay/deps.js +3 -1
- package/esm/foundation/product-processor/easysafepay/index.d.ts +5 -0
- package/esm/foundation/product-processor/easysafepay/index.js +267 -128
- package/esm/foundation/product-processor/element/index.d.ts +7 -0
- package/esm/foundation/product-processor/element/index.js +24 -0
- package/esm/foundation/service/container/index.d.ts +12 -3
- package/esm/foundation/service/container/index.js +145 -16
- package/esm/foundation/service/container/popup.d.ts +1 -1
- package/esm/foundation/service/event-center.js +1 -0
- package/esm/foundation/service/log/keys.js +3 -1
- package/esm/foundation/service/log/types.d.ts +1 -0
- package/esm/foundation/service/requester/requester.js +5 -4
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +8 -4
- package/esm/foundation/utils/redirect_utils.js +34 -18
- package/esm/foundation/utils/web_app_url_utils.d.ts +71 -1
- package/esm/foundation/utils/web_app_url_utils.js +219 -8
- package/esm/index.d.ts +7 -4
- package/esm/index.js +98 -48
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +5 -5
- package/esm/plugin/component/channel.d.ts +3 -1
- package/esm/plugin/component/channel.js +10 -12
- package/esm/plugin/component/index.js +47 -44
- package/esm/plugin/type.d.ts +1 -1
- package/esm/types/index.d.ts +37 -3
- package/esm/types/index.js +10 -2
- package/esm/util/index.d.ts +7 -1
- package/esm/util/index.js +10 -1
- package/esm/util/redirect.d.ts +6 -0
- package/esm/util/redirect.js +54 -0
- package/package.json +27 -4
- /package/esm/core/component/{element → oldElement}/components/address.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/components/address.js +0 -0
- /package/esm/core/component/{element → oldElement}/components/auth.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/components/auth.js +0 -0
- /package/esm/core/component/{element → oldElement}/components/payment.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/components/payment.js +0 -0
- /package/esm/core/component/{element → oldElement}/utils.d.ts +0 -0
- /package/esm/core/component/{element → oldElement}/utils.js +0 -0
@@ -1,30 +1,39 @@
|
|
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
|
-
|
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
|
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
|
+
getWebApp(): HTMLIFrameElement;
|
30
39
|
}
|
@@ -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 {
|
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 {
|
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
|
}
|
@@ -43,11 +48,18 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
43
48
|
value: function init(initOptions, instanceId, sdkMetaData) {
|
44
49
|
this.instanceId = instanceId;
|
45
50
|
this.sdkMetaData = sdkMetaData;
|
51
|
+
this.clientHeight = Math.max(window.innerHeight, window.visualViewport.height);
|
46
52
|
this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
|
47
53
|
this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
|
48
54
|
this.popupManager = new PopupManager();
|
49
|
-
|
55
|
+
// element因涉及多组件联动,消息接受处理在产品层进行
|
56
|
+
var notAddEventCenter = Boolean(Object.keys(initOptions).length) && sdkMetaData.productScene === ProductSceneEnum.ELEMENT_PAYMENT;
|
57
|
+
if (!notAddEventCenter) {
|
58
|
+
this.addCapabilityToEventCenter();
|
59
|
+
}
|
50
60
|
this.addCapabilityToApiBusManager();
|
61
|
+
// bind会返回一个新的方法,init时记录上这个focus,不然window.addEventListener时this指向会变成window
|
62
|
+
this.boundFocusResizeChange = this.focusResizeChange.bind(this);
|
51
63
|
}
|
52
64
|
}, {
|
53
65
|
key: "update",
|
@@ -55,10 +67,21 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
55
67
|
}, {
|
56
68
|
key: "load",
|
57
69
|
value: function load(displayInfo, url, closeBtnFunc) {
|
58
|
-
var
|
70
|
+
var appendAliasContainerId = displayInfo.appendAliasContainerId,
|
71
|
+
selector = displayInfo.selector,
|
72
|
+
type = displayInfo.type,
|
73
|
+
platform = displayInfo.platform;
|
74
|
+
var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(selector) : ''));
|
75
|
+
if (!isEmpty(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle)) {
|
76
|
+
Object.keys(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle).forEach(function (key) {
|
77
|
+
var _displayInfo$iframeSt;
|
78
|
+
webApp.style[key] = displayInfo === null || displayInfo === void 0 || (_displayInfo$iframeSt = displayInfo.iframeStyle) === null || _displayInfo$iframeSt === void 0 ? void 0 : _displayInfo$iframeSt[key];
|
79
|
+
});
|
80
|
+
}
|
59
81
|
this.webApp = webApp;
|
60
82
|
this.displayInfo = displayInfo;
|
61
83
|
webApp.src = url;
|
84
|
+
webApp.allow = 'payment';
|
62
85
|
this.eventCenter.addIFrame(webApp);
|
63
86
|
if (webApp.src.includes('?')) {
|
64
87
|
this.popupManager.setPopupUrlQuery(webApp.src.split('?')[1]);
|
@@ -66,7 +89,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
66
89
|
// TODO call ApiBusManager to add listener to iframe, componentApp line 979
|
67
90
|
|
68
91
|
// create container and append web app
|
69
|
-
var container =
|
92
|
+
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
93
|
container.appendChild(webApp);
|
71
94
|
return container;
|
72
95
|
}
|
@@ -75,7 +98,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
75
98
|
value: function cleanContainer(displayInfo) {
|
76
99
|
var _document$getElementB;
|
77
100
|
// selector and container
|
78
|
-
var selector = displayInfo.type === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
|
101
|
+
var selector = (displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.type) === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
|
79
102
|
var selectorDom = document.querySelector(selector);
|
80
103
|
if (selectorDom) {
|
81
104
|
selectorDom.innerHTML = '';
|
@@ -86,7 +109,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
86
109
|
this.eventCenter.cleanIFrames();
|
87
110
|
|
88
111
|
// animation
|
89
|
-
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
112
|
+
(_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
113
|
}
|
91
114
|
}, {
|
92
115
|
key: "showLoading",
|
@@ -138,6 +161,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
138
161
|
container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.displayInfo.platform));
|
139
162
|
}
|
140
163
|
}
|
164
|
+
}, {
|
165
|
+
key: "handleAccountFocus",
|
166
|
+
value: function handleAccountFocus(focus) {
|
167
|
+
var _window$visualViewpor, _window;
|
168
|
+
// 失焦时v2会走默认的sizeChange还原高度,这里仅移除监听
|
169
|
+
(_window$visualViewpor = window.visualViewport) === null || _window$visualViewpor === void 0 || _window$visualViewpor.removeEventListener('resize', this.boundFocusResizeChange);
|
170
|
+
(_window = window) === null || _window === void 0 || _window.removeEventListener('resize', this.boundFocusResizeChange);
|
171
|
+
// 只有聚焦才监听,失焦后移除,避免影响别的场景
|
172
|
+
if (focus) {
|
173
|
+
var _window$visualViewpor2;
|
174
|
+
// 监听页面visualViewport的高度变化,适用于主流机型更精准获取当前页面高度
|
175
|
+
(_window$visualViewpor2 = window.visualViewport) === null || _window$visualViewpor2 === void 0 || _window$visualViewpor2.addEventListener('resize', this.boundFocusResizeChange);
|
176
|
+
// 兼容visualViewport处理不到的场景,一般存在于老版本浏览器
|
177
|
+
window.addEventListener('resize', this.boundFocusResizeChange);
|
178
|
+
}
|
179
|
+
}
|
141
180
|
}, {
|
142
181
|
key: "addCapabilityToEventCenter",
|
143
182
|
value: function addCapabilityToEventCenter() {
|
@@ -158,9 +197,12 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
158
197
|
this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
|
159
198
|
var _this$displayInfo2;
|
160
199
|
if (data.paymentElementOldModel) return;
|
200
|
+
insertStyleSheet();
|
161
201
|
_this.popupManager.popup(_objectSpread({
|
162
202
|
platform: (_this$displayInfo2 = _this.displayInfo) === null || _this$displayInfo2 === void 0 ? void 0 : _this$displayInfo2.platform
|
163
|
-
}, data)).
|
203
|
+
}, data)).then(function () {
|
204
|
+
_this.eventCenter.addIFrame(_this.popupManager.popupApp);
|
205
|
+
}).catch(function (error) {
|
164
206
|
_this.logService.logError({
|
165
207
|
title: (error === null || error === void 0 ? void 0 : error.title) || 'sdk_error_create_pop_up'
|
166
208
|
}, error);
|
@@ -173,7 +215,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
173
215
|
this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
174
216
|
_this.handleSizeChanged(_objectSpread({}, data));
|
175
217
|
});
|
176
|
-
this.eventCenter.listen(EVENT.showCloseButton.name, function () {
|
218
|
+
this.eventCenter.listen(EVENT.showCloseButton.name, function (data) {
|
219
|
+
_this.handleCloseButtonTheme(data.style);
|
177
220
|
_this.changeCloseBtnVisibility(true);
|
178
221
|
});
|
179
222
|
this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
|
@@ -185,6 +228,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
185
228
|
this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
|
186
229
|
_this.handleAppHeartBeat();
|
187
230
|
});
|
231
|
+
/**
|
232
|
+
* 目前仅用于ESP V2的 web sdk
|
233
|
+
* 原因: 在账户输入页和OTP页面的h5场景下键盘弹起页面会有问题,iframe有固定高度,键盘弹起时应用层不会触发大小变化
|
234
|
+
* account账号输入页需要在sdk监听键盘弹起后高度变化并修改iframe及iframe外层容器,account需要按钮置底的放在键盘上面,必须修改高度而不是让容器定位
|
235
|
+
* otp页面需要在聚焦时给iframe及外层容器设置fixed定位,让页面不被弹起
|
236
|
+
* 目的: esp页面输入框聚焦/失焦后给sdk发送消息
|
237
|
+
*/
|
238
|
+
this.eventCenter.listen(EVENT.inputFocus.name, function (data) {
|
239
|
+
// 账号输入页需要修改iframe高度
|
240
|
+
if (data.source === 'ESP_V2' && data.type === 'account') {
|
241
|
+
_this.handleAccountFocus(data.focus);
|
242
|
+
// otp页面需要定位元素
|
243
|
+
} else if (data.source === 'ESP_V2' && data.type === 'otp') {
|
244
|
+
_this.focusScrollFixed(data.focus);
|
245
|
+
}
|
246
|
+
});
|
188
247
|
}
|
189
248
|
}, {
|
190
249
|
key: "addCapabilityToApiBusManager",
|
@@ -207,22 +266,26 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
207
266
|
}, {
|
208
267
|
key: "handleSizeChanged",
|
209
268
|
value: function handleSizeChanged(data) {
|
269
|
+
var _this$displayInfo3 = this.displayInfo,
|
270
|
+
appendAliasContainerId = _this$displayInfo3.appendAliasContainerId,
|
271
|
+
selector = _this$displayInfo3.selector;
|
272
|
+
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
273
|
if (!this.webApp || !this.displayInfo) {
|
211
274
|
return;
|
212
275
|
}
|
213
|
-
var cashier = document.getElementById(
|
214
|
-
if ((data === null || data === void 0 ? void 0 : data.height) <= 1 || data.height === parseInt(cashier.style.height)) return;
|
276
|
+
var cashier = document.getElementById(cashierId);
|
277
|
+
if (!cashier || (data === null || data === void 0 ? void 0 : data.height) <= 1 || data.height === parseInt(cashier.style.height)) return;
|
215
278
|
cashier.style.height = "".concat(data.height, "px");
|
216
279
|
this.webApp.style.opacity = '1';
|
217
280
|
if (this.displayInfo.type === DisplayTypeEnum.popup) {
|
218
281
|
if (this.displayInfo.platform === 'desktop') {
|
219
282
|
if (data.width) cashier.style.width = "".concat(data.width, "px");
|
220
|
-
cashier.classList.add("".concat(
|
283
|
+
cashier.classList.add("".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation"));
|
221
284
|
this.webApp.style.height = "".concat(data.height, "px");
|
222
285
|
}
|
223
286
|
if (this.displayInfo.platform === 'mobile') {
|
224
|
-
cashier.classList.add("".concat(
|
225
|
-
var animationStyleId = "".concat(
|
287
|
+
cashier.classList.add("".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation"));
|
288
|
+
var animationStyleId = "".concat(cashierId, "-").concat(this.displayInfo.platform, "-animation-style");
|
226
289
|
var animationStyle = document.getElementById(animationStyleId);
|
227
290
|
if (animationStyle) animationStyle === null || animationStyle === void 0 || animationStyle.remove();
|
228
291
|
|
@@ -241,6 +304,50 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
241
304
|
this.webApp.style.height = "".concat(data.height, "px");
|
242
305
|
}
|
243
306
|
}
|
307
|
+
|
308
|
+
// 目前仅用于esp账号输入页聚焦
|
309
|
+
}, {
|
310
|
+
key: "focusResizeChange",
|
311
|
+
value: function focusResizeChange() {
|
312
|
+
var _window2;
|
313
|
+
// 计算出当前iframe应有的高度,需要和顶部留有距离
|
314
|
+
var webPageHeightRatio = 0.9;
|
315
|
+
var browserPageHeightFocusRatio = 0.9;
|
316
|
+
// sdk层才能拿到当前键盘弹起后页面的高度
|
317
|
+
var height = ((_window2 = window) === null || _window2 === void 0 || (_window2 = _window2.visualViewport) === null || _window2 === void 0 ? void 0 : _window2.height) || window.innerHeight;
|
318
|
+
height = height * webPageHeightRatio;
|
319
|
+
height = height * browserPageHeightFocusRatio;
|
320
|
+
// 调用handleSizeChanged修改iframe高度
|
321
|
+
this.handleSizeChanged({
|
322
|
+
width: 0,
|
323
|
+
height: height
|
324
|
+
});
|
325
|
+
}
|
326
|
+
|
327
|
+
// 目前仅用于esp otp页面账号聚焦
|
328
|
+
}, {
|
329
|
+
key: "focusScrollFixed",
|
330
|
+
value: function focusScrollFixed(focus) {
|
331
|
+
// 获取iframe dom元素
|
332
|
+
var _this$displayInfo4 = this.displayInfo,
|
333
|
+
appendAliasContainerId = _this$displayInfo4.appendAliasContainerId,
|
334
|
+
selector = _this$displayInfo4.selector;
|
335
|
+
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;
|
336
|
+
if (!this.webApp || !this.displayInfo) {
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
var cashier = document.getElementById(cashierId);
|
340
|
+
if (!cashier) return;
|
341
|
+
// 输入框聚焦时修改定位信息和top距离
|
342
|
+
if (focus) {
|
343
|
+
cashier.style.setProperty('position', 'fixed', 'important');
|
344
|
+
cashier.style.setProperty('top', "".concat(this.clientHeight - cashier.clientHeight, "px"), 'important');
|
345
|
+
} else {
|
346
|
+
// 失焦时移除定位信息
|
347
|
+
cashier.style.removeProperty('position');
|
348
|
+
cashier.style.removeProperty('top');
|
349
|
+
}
|
350
|
+
}
|
244
351
|
}, {
|
245
352
|
key: "handleAppHeartBeat",
|
246
353
|
value: function handleAppHeartBeat() {
|
@@ -298,6 +405,28 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
298
405
|
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-hidden"));
|
299
406
|
}
|
300
407
|
}
|
408
|
+
}, {
|
409
|
+
key: "handleCloseButtonTheme",
|
410
|
+
value: function handleCloseButtonTheme(style) {
|
411
|
+
if (!style) return;
|
412
|
+
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
413
|
+
var closeButtonImg = closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.querySelector('img');
|
414
|
+
var maskCloseBlock = document.getElementById(COMPONENT_CLOSE_MASK_BLOCK_ID);
|
415
|
+
if (style === 'light') {
|
416
|
+
closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImgLight);
|
417
|
+
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
|
418
|
+
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
419
|
+
} else {
|
420
|
+
closeButtonImg === null || closeButtonImg === void 0 || closeButtonImg.setAttribute('src', closeImg);
|
421
|
+
closeBlock === null || closeBlock === void 0 || closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-light"));
|
422
|
+
maskCloseBlock === null || maskCloseBlock === void 0 || maskCloseBlock.classList.remove("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-light"));
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}, {
|
426
|
+
key: "getWebApp",
|
427
|
+
value: function getWebApp() {
|
428
|
+
return this.webApp;
|
429
|
+
}
|
301
430
|
}]);
|
302
431
|
return ContainerService;
|
303
432
|
}();
|
@@ -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: {
|
@@ -86,7 +86,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
86
86
|
time: Date.now() - startTime,
|
87
87
|
success: false,
|
88
88
|
code: errorCode,
|
89
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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":
|
@@ -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
|
};
|
@@ -8,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
8
8
|
import { sdkVersion } from "../../config";
|
9
9
|
import { createPreloadIframe } from "../service/container/utils";
|
10
10
|
import { ProductSceneEnum } from "../../types";
|
11
|
-
import { getWebAppUrl } from "../utils/web_app_url_utils";
|
11
|
+
import { getWebAppUrl, getWebAppV2Url } from "../utils/web_app_url_utils";
|
12
12
|
import { ProductInfoCacheUtil } from "../utils/payment_product_utils";
|
13
13
|
import { getWebAppVersion } from "./payment_context_utils";
|
14
14
|
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security } from "../../util/security";
|
@@ -22,12 +22,13 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
22
22
|
key: "preloadWebApp",
|
23
23
|
value: function preloadWebApp(productScene, paymentMethodCategoryType) {
|
24
24
|
var environment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'prod';
|
25
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
25
26
|
try {
|
26
27
|
if (this.isWebAppPreloaded) {
|
27
28
|
console.log('[web-sdk] web app already preloaded');
|
28
29
|
return;
|
29
30
|
}
|
30
|
-
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
|
31
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment, useV2),
|
31
32
|
preloadUrl = _this$buildWebAppPrel.preloadUrl,
|
32
33
|
containerId = _this$buildWebAppPrel.containerId;
|
33
34
|
var preloadIframe = createPreloadIframe(containerId);
|
@@ -89,6 +90,7 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
89
90
|
}, {
|
90
91
|
key: "buildWebAppPreloadUrl",
|
91
92
|
value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
|
93
|
+
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
92
94
|
var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
|
93
95
|
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
|
94
96
|
if (previousProductInfo) {
|
@@ -101,14 +103,16 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
101
103
|
webAppVersion: ''
|
102
104
|
};
|
103
105
|
sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
|
104
|
-
var
|
106
|
+
var preloadUrlParams = {
|
105
107
|
environment: environment,
|
106
108
|
sdkMetaData: sdkMetaData,
|
107
109
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
108
110
|
isPreload: true,
|
111
|
+
productScene: productScene,
|
109
112
|
productSceneVersion: productSceneVersion,
|
110
113
|
query: undefined
|
111
|
-
}
|
114
|
+
};
|
115
|
+
var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
|
112
116
|
return {
|
113
117
|
preloadUrl: preloadUrl,
|
114
118
|
containerId: containerId
|
@@ -69,26 +69,42 @@ export var redirect = function redirect(payload, instanceId) {
|
|
69
69
|
successCallback(payload, type, evokeAppBy.url, serviceProvider);
|
70
70
|
}
|
71
71
|
});
|
72
|
+
var callApplinkUrl = function callApplinkUrl() {
|
73
|
+
try {
|
74
|
+
callAppLib.open({
|
75
|
+
link: payload.applinkUrl,
|
76
|
+
fallback: function fallback() {
|
77
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
78
|
+
// Applink evoke failed, try to use scheme url
|
79
|
+
callSchemeUrl();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
} catch (error) {
|
83
|
+
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
84
|
+
// Applink evoke failed, try to use scheme url
|
85
|
+
callSchemeUrl();
|
86
|
+
}
|
87
|
+
};
|
72
88
|
var callSchemeUrl = function callSchemeUrl() {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
89
|
+
try {
|
90
|
+
callAppLib.open({
|
91
|
+
scheme: payload.schemeUrl,
|
92
|
+
fallback: function fallback() {
|
93
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
94
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
95
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
96
|
+
window.location.href = payload.url;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
} catch (error) {
|
100
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
101
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
102
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
103
|
+
window.location.href = payload.url;
|
104
|
+
}
|
82
105
|
};
|
83
106
|
if (payload.applinkUrl) {
|
84
|
-
|
85
|
-
link: payload.applinkUrl,
|
86
|
-
fallback: function fallback() {
|
87
|
-
failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
|
88
|
-
// Applink evoke failed, try to use scheme url
|
89
|
-
callSchemeUrl();
|
90
|
-
}
|
91
|
-
});
|
107
|
+
callApplinkUrl();
|
92
108
|
} else if (payload.schemeUrl) {
|
93
109
|
callSchemeUrl();
|
94
110
|
}
|
@@ -116,7 +132,7 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
|
|
116
132
|
};
|
117
133
|
var failCallback = function failCallback(payload, type, url, serviceProvider) {
|
118
134
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
119
|
-
code: eventCodeEnum.
|
135
|
+
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
120
136
|
message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
|
121
137
|
});
|
122
138
|
serviceProvider.getService('Log').logInfo({
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { ESP_PAGE_NAME } from '../../constant/easysafepay';
|
2
|
+
import { DisplayTypeEnum, IPaymentSessionMetaData, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from '../../types';
|
2
3
|
import { SDKMetaData } from '../index';
|
3
4
|
/**
|
4
5
|
* Tell the SDK which version of the Web App to load.
|
@@ -16,6 +17,16 @@ export interface WebAppMatchConfig {
|
|
16
17
|
mid?: string;
|
17
18
|
greyscale?: string;
|
18
19
|
}
|
20
|
+
/**
|
21
|
+
* Tell the SDK which Web App URL to load.
|
22
|
+
* Sent by server inside paymentSession.
|
23
|
+
*/
|
24
|
+
export interface WebAppUrlMatchConfig {
|
25
|
+
minSDKVersion: string;
|
26
|
+
url: string;
|
27
|
+
doubleFa: string;
|
28
|
+
mids?: string[];
|
29
|
+
}
|
19
30
|
export interface QueryParams {
|
20
31
|
displayType: DisplayTypeEnum;
|
21
32
|
locale: string;
|
@@ -27,20 +38,79 @@ export interface QueryParams {
|
|
27
38
|
export declare const getWebAppUrlInfo: (params: {
|
28
39
|
environment: string;
|
29
40
|
sdkMetaData: SDKMetaData;
|
41
|
+
productScene: ProductSceneEnum;
|
30
42
|
productSceneVersion: string;
|
31
43
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
32
44
|
isPreload?: boolean;
|
33
45
|
query: QueryParams;
|
46
|
+
v2Url?: string;
|
34
47
|
}) => {
|
35
48
|
path: string;
|
36
49
|
locationSearch: string;
|
37
50
|
};
|
51
|
+
export declare const getWebAppV2Url: (params: {
|
52
|
+
environment: string;
|
53
|
+
sdkMetaData: SDKMetaData;
|
54
|
+
productScene: ProductSceneEnum;
|
55
|
+
productSceneVersion: string;
|
56
|
+
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
57
|
+
isPreload?: boolean;
|
58
|
+
query: QueryParams;
|
59
|
+
mid?: string;
|
60
|
+
extendInfo?: string;
|
61
|
+
}) => string;
|
38
62
|
export declare const getWebAppUrl: (params: {
|
39
63
|
environment: string;
|
40
64
|
sdkMetaData: SDKMetaData;
|
65
|
+
productScene: ProductSceneEnum;
|
41
66
|
productSceneVersion: string;
|
42
67
|
paymentMethodCategoryType: PaymentMethodCategoryTypeEnum;
|
43
68
|
isPreload?: boolean;
|
44
69
|
query: QueryParams;
|
70
|
+
v2Url?: string;
|
45
71
|
}) => string;
|
46
72
|
export declare const parseWebAppMatchConfig: (extendInfo: string) => WebAppMatchConfig[];
|
73
|
+
export declare const parseWebAppUrlMatchConfig: (extendInfo: string) => WebAppUrlMatchConfig[];
|
74
|
+
/**
|
75
|
+
* Save the current checkout URL to localStorage for the specified product scene.
|
76
|
+
*
|
77
|
+
* @param productScene - The product scene for which the checkout URL should be saved.
|
78
|
+
*/
|
79
|
+
export declare const saveLocalCheckoutUrl: (productScene: ProductSceneEnum, url: string) => void;
|
80
|
+
/**
|
81
|
+
* 获取从外部动态下发的V2AppUrl.
|
82
|
+
*
|
83
|
+
* @param config - sessionData解析来的checkoutInfo列表.
|
84
|
+
*/
|
85
|
+
export declare const getMatchedWebAppV2Url: (productScene: ProductSceneEnum, mid: string, configs: WebAppUrlMatchConfig[], env: string) => string;
|
86
|
+
/**
|
87
|
+
* 获取ESP从sessionData.checkoutInfo内动态下发的Url.
|
88
|
+
*/
|
89
|
+
export declare const matchEasySafePayV2Url: (params: {
|
90
|
+
configs: WebAppUrlMatchConfig[];
|
91
|
+
mid: string;
|
92
|
+
env: string;
|
93
|
+
pageName: ESP_PAGE_NAME;
|
94
|
+
}) => string;
|
95
|
+
/**
|
96
|
+
* Retrieve the saved checkout URL from localStorage for the specified product scene.
|
97
|
+
* If no url is found, a default checkout url string is returned.
|
98
|
+
*
|
99
|
+
* @param productScene - The product scene for which the checkout URL should be retrieved.
|
100
|
+
*/
|
101
|
+
export declare const getLocalCheckoutUrl: (productScene: ProductSceneEnum, environment: string) => string;
|
102
|
+
/**
|
103
|
+
* Provide default checkout URL for the specified product scene.
|
104
|
+
* Return URL for 'EASY_PAY' product scene, while for other product scenes, it returns an empty string as they are not currently in use
|
105
|
+
*
|
106
|
+
* @param productScene - The product scene for which the default checkout URL should be provided.
|
107
|
+
*/
|
108
|
+
export declare const defaultCheckoutUrl: (productScene: ProductSceneEnum, environment?: string) => string;
|
109
|
+
/**
|
110
|
+
* V2应用EasySafePay 热更新兜底URL构建规则
|
111
|
+
* 1. 兜底URL版本与sdk版本保持一致
|
112
|
+
* 2. DEV环境下html新增版本前缀
|
113
|
+
**/
|
114
|
+
export declare const getDefaultEasySafePayPageUrl: (pageName: ESP_PAGE_NAME, env: string) => string;
|
115
|
+
/**通过sessionData获取doubleFa,于createComponent时传递给WEB应用*/
|
116
|
+
export declare const getDoubleFaUrlFromSession: (paymentSessionObj: IPaymentSessionMetaData, env?: string) => string;
|