@alipay/ams-checkout 0.0.1755253657-dev.2 → 0.0.1755258862-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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/component/channel.d.ts +1 -3
- package/esm/component/channel.js +62 -26
- package/esm/component/component.inline.style.js +2 -2
- package/esm/component/popupWindow.style.d.ts +1 -4
- package/esm/component/popupWindow.style.js +2 -37
- package/esm/config/index.d.ts +8 -8
- package/esm/config/index.js +8 -8
- package/esm/constant/index.d.ts +2 -41
- package/esm/constant/index.js +5 -43
- package/esm/core/component/ckp/index.d.ts +0 -2
- package/esm/core/component/ckp/index.js +5 -41
- package/esm/core/component/element/index.d.ts +46 -7
- package/esm/core/component/element/index.js +923 -31
- package/esm/core/component/element/mock.d.ts +0 -4
- package/esm/core/component/element/mock.js +1 -365
- package/esm/core/component/element/type.d.ts +34 -74
- package/esm/core/component/element/type.js +12 -20
- package/esm/core/component/index.d.ts +1 -5
- package/esm/core/component/index.js +2 -1
- package/esm/core/instance/index.d.ts +1 -1
- package/esm/core/instance/index.js +1 -1
- package/esm/foundation/core/index.d.ts +1 -9
- package/esm/foundation/core/index.js +49 -153
- package/esm/foundation/index.d.ts +0 -20
- package/esm/foundation/index.js +2 -13
- package/esm/foundation/product-processor/easysafepay/deps.d.ts +1 -3
- package/esm/foundation/product-processor/easysafepay/deps.js +1 -3
- package/esm/foundation/product-processor/easysafepay/index.d.ts +0 -5
- package/esm/foundation/product-processor/easysafepay/index.js +137 -313
- package/esm/foundation/service/container/index.d.ts +3 -14
- package/esm/foundation/service/container/index.js +25 -178
- package/esm/foundation/service/container/popup.d.ts +7 -10
- package/esm/foundation/service/container/popup.js +1 -3
- package/esm/foundation/service/event-center.js +0 -1
- package/esm/foundation/service/log/keys.js +1 -3
- package/esm/foundation/service/log/types.d.ts +0 -1
- package/esm/foundation/service/requester/requester.js +6 -7
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +4 -8
- package/esm/foundation/utils/redirect_utils.js +18 -34
- package/esm/foundation/utils/web_app_url_utils.d.ts +1 -71
- package/esm/foundation/utils/web_app_url_utils.js +8 -219
- package/esm/index.d.ts +4 -7
- package/esm/index.js +48 -98
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +5 -5
- package/esm/plugin/component/channel.d.ts +1 -3
- package/esm/plugin/component/channel.js +12 -10
- package/esm/plugin/component/index.js +44 -47
- package/esm/plugin/type.d.ts +1 -1
- package/esm/request/index.js +2 -2
- package/esm/types/index.d.ts +3 -37
- package/esm/types/index.js +2 -10
- package/esm/util/index.d.ts +1 -8
- package/esm/util/index.js +3 -31
- package/esm/util/spm-map.d.ts +4 -18
- package/esm/util/spm-map.js +6 -20
- package/package.json +4 -27
- package/esm/constant/easysafepay.d.ts +0 -16
- package/esm/constant/easysafepay.js +0 -19
- package/esm/core/component/element/elementContainerService/containerService.d.ts +0 -33
- package/esm/core/component/element/elementContainerService/containerService.js +0 -123
- package/esm/core/component/element/elementContainerService/index.d.ts +0 -20
- package/esm/core/component/element/elementContainerService/index.js +0 -63
- package/esm/core/component/element/elementController/index.d.ts +0 -27
- package/esm/core/component/element/elementController/index.js +0 -493
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/addressProcessor.js +0 -160
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/authProcessor.js +0 -125
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +0 -41
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +0 -96
- package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +0 -20
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +0 -380
- package/esm/core/component/element/util.d.ts +0 -69
- package/esm/core/component/element/util.js +0 -477
- package/esm/core/component/oldElement/index.d.ts +0 -59
- package/esm/core/component/oldElement/index.js +0 -956
- package/esm/core/component/oldElement/mock.d.ts +0 -6
- package/esm/core/component/oldElement/mock.js +0 -567
- package/esm/core/component/oldElement/type.d.ts +0 -354
- package/esm/core/component/oldElement/type.js +0 -81
- package/esm/foundation/product-processor/autoDebit/deps.d.ts +0 -14
- package/esm/foundation/product-processor/autoDebit/deps.js +0 -12
- package/esm/foundation/product-processor/autoDebit/index.d.ts +0 -48
- package/esm/foundation/product-processor/autoDebit/index.js +0 -466
- package/esm/foundation/product-processor/element/index.d.ts +0 -7
- package/esm/foundation/product-processor/element/index.js +0 -24
- package/esm/util/redirect.d.ts +0 -6
- package/esm/util/redirect.js +0 -54
- /package/esm/core/component/{oldElement → element}/components/address.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/address.js +0 -0
- /package/esm/core/component/{oldElement → element}/components/auth.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/auth.js +0 -0
- /package/esm/core/component/{oldElement → element}/components/payment.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/components/payment.js +0 -0
- /package/esm/core/component/{oldElement → element}/utils.d.ts +0 -0
- /package/esm/core/component/{oldElement → element}/utils.js +0 -0
@@ -1,41 +1,30 @@
|
|
1
|
-
import { IoptionsParams } from '../../../types';
|
2
1
|
import { DisplayInfo, SDKMetaData, Service } from '../../index';
|
3
|
-
import {
|
2
|
+
import { IoptionsParams } from '../../../types';
|
4
3
|
export declare class ContainerService implements Service {
|
5
4
|
private instanceId;
|
6
5
|
private sdkMetaData;
|
7
|
-
private initMessageEvent;
|
8
6
|
private clearTimerIdMapping;
|
9
|
-
popupManager
|
7
|
+
private popupManager;
|
10
8
|
private eventCenter;
|
11
9
|
private logService;
|
12
10
|
private displayInfo;
|
13
11
|
private webApp;
|
14
12
|
private _webAppHeartBeatTimeoutFn;
|
15
|
-
private clientHeight;
|
16
|
-
private boundFocusResizeChange;
|
17
13
|
private customizedLoadingListener;
|
18
14
|
destroy(): void;
|
19
15
|
init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
|
20
16
|
update(): void;
|
21
|
-
load(displayInfo: DisplayInfo, url: string, closeBtnFunc
|
17
|
+
load(displayInfo: DisplayInfo, url: string, closeBtnFunc: () => void): HTMLDivElement;
|
22
18
|
cleanContainer(displayInfo: DisplayInfo): void;
|
23
19
|
showLoading(container: HTMLDivElement, displayInfo: DisplayInfo): void;
|
24
20
|
dismissLoading(isKeepMockup?: boolean): void;
|
25
21
|
customizeLoading(listener: (event: 'SDK_START_OF_LOADING' | 'SDK_END_OF_LOADING') => void): void;
|
26
22
|
startHideAnim(): void;
|
27
|
-
private handleAccountFocus;
|
28
23
|
private addCapabilityToEventCenter;
|
29
24
|
private addCapabilityToApiBusManager;
|
30
25
|
private updateMaskCloseBtn;
|
31
26
|
private handleSizeChanged;
|
32
|
-
private focusResizeChange;
|
33
|
-
private focusScrollFixed;
|
34
27
|
private handleAppHeartBeat;
|
35
28
|
private changeCloseBtnVisibility;
|
36
29
|
private handleMaskCloseBtnShow;
|
37
|
-
private handleCloseButtonTheme;
|
38
|
-
private handlePopupWindow;
|
39
|
-
private handlePopWindow;
|
40
|
-
getWebApp(): HTMLIFrameElement;
|
41
30
|
}
|
@@ -7,16 +7,14 @@ 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 {
|
10
|
+
import { DisplayTypeEnum } from "../../../types";
|
11
|
+
import { createIframe, startSizeChangeAnim } from "./utils";
|
11
12
|
import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
|
12
13
|
import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
|
13
|
-
import {
|
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";
|
14
|
+
import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CLOSE_MASK_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, LOADING_ID, MOCKUP_ID } from "../../../constant";
|
16
15
|
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
|
-
|
20
18
|
/**
|
21
19
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
22
20
|
* @date 2024/9/17
|
@@ -27,7 +25,6 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
27
25
|
_classCallCheck(this, ContainerService);
|
28
26
|
_defineProperty(this, "instanceId", void 0);
|
29
27
|
_defineProperty(this, "sdkMetaData", void 0);
|
30
|
-
_defineProperty(this, "initMessageEvent", void 0);
|
31
28
|
_defineProperty(this, "clearTimerIdMapping", {});
|
32
29
|
_defineProperty(this, "popupManager", void 0);
|
33
30
|
_defineProperty(this, "eventCenter", void 0);
|
@@ -35,8 +32,6 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
35
32
|
_defineProperty(this, "displayInfo", void 0);
|
36
33
|
_defineProperty(this, "webApp", void 0);
|
37
34
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
38
|
-
_defineProperty(this, "clientHeight", void 0);
|
39
|
-
_defineProperty(this, "boundFocusResizeChange", void 0);
|
40
35
|
// if this variable is true, SDK will invoke listener instead of showing loading
|
41
36
|
_defineProperty(this, "customizedLoadingListener", void 0);
|
42
37
|
}
|
@@ -46,21 +41,13 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
46
41
|
}, {
|
47
42
|
key: "init",
|
48
43
|
value: function init(initOptions, instanceId, sdkMetaData) {
|
49
|
-
var _window;
|
50
44
|
this.instanceId = instanceId;
|
51
45
|
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);
|
53
46
|
this.eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
|
54
47
|
this.logService = ServiceProvider.getInstance(instanceId).getService('Log');
|
55
48
|
this.popupManager = new PopupManager();
|
56
|
-
|
57
|
-
var notAddEventCenter = Boolean(Object.keys(initOptions).length) && sdkMetaData.productScene === ProductSceneEnum.ELEMENT_PAYMENT;
|
58
|
-
if (!notAddEventCenter) {
|
59
|
-
this.addCapabilityToEventCenter();
|
60
|
-
}
|
49
|
+
this.addCapabilityToEventCenter();
|
61
50
|
this.addCapabilityToApiBusManager();
|
62
|
-
// bind会返回一个新的方法,init时记录上这个focus,不然window.addEventListener时this指向会变成window
|
63
|
-
this.boundFocusResizeChange = this.focusResizeChange.bind(this);
|
64
51
|
}
|
65
52
|
}, {
|
66
53
|
key: "update",
|
@@ -68,21 +55,10 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
68
55
|
}, {
|
69
56
|
key: "load",
|
70
57
|
value: function load(displayInfo, url, closeBtnFunc) {
|
71
|
-
var
|
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
|
-
}
|
58
|
+
var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(displayInfo.selector) : ''));
|
82
59
|
this.webApp = webApp;
|
83
60
|
this.displayInfo = displayInfo;
|
84
61
|
webApp.src = url;
|
85
|
-
webApp.allow = 'payment';
|
86
62
|
this.eventCenter.addIFrame(webApp);
|
87
63
|
if (webApp.src.includes('?')) {
|
88
64
|
this.popupManager.setPopupUrlQuery(webApp.src.split('?')[1]);
|
@@ -90,7 +66,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
90
66
|
// TODO call ApiBusManager to add listener to iframe, componentApp line 979
|
91
67
|
|
92
68
|
// create container and append web app
|
93
|
-
var container = type === DisplayTypeEnum.inline ? createInlineBaseElement(
|
69
|
+
var container = displayInfo.type === DisplayTypeEnum.inline ? createInlineBaseElement(displayInfo.selector) : createBaseElement(displayInfo.platform, closeBtnFunc);
|
94
70
|
container.appendChild(webApp);
|
95
71
|
return container;
|
96
72
|
}
|
@@ -99,7 +75,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
99
75
|
value: function cleanContainer(displayInfo) {
|
100
76
|
var _document$getElementB;
|
101
77
|
// selector and container
|
102
|
-
var selector =
|
78
|
+
var selector = displayInfo.type === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
|
103
79
|
var selectorDom = document.querySelector(selector);
|
104
80
|
if (selectorDom) {
|
105
81
|
selectorDom.innerHTML = '';
|
@@ -110,7 +86,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
110
86
|
this.eventCenter.cleanIFrames();
|
111
87
|
|
112
88
|
// animation
|
113
|
-
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo
|
89
|
+
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
114
90
|
}
|
115
91
|
}, {
|
116
92
|
key: "showLoading",
|
@@ -162,22 +138,6 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
162
138
|
container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.displayInfo.platform));
|
163
139
|
}
|
164
140
|
}
|
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
|
-
}
|
181
141
|
}, {
|
182
142
|
key: "addCapabilityToEventCenter",
|
183
143
|
value: function addCapabilityToEventCenter() {
|
@@ -196,7 +156,16 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
196
156
|
});
|
197
157
|
});
|
198
158
|
this.eventCenter.listen(EVENT.popupWindow.name, function (data) {
|
199
|
-
_this
|
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
|
+
});
|
200
169
|
});
|
201
170
|
this.eventCenter.listen(EVENT.popWindow.name, function () {
|
202
171
|
_this.popupManager.pop();
|
@@ -204,8 +173,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
204
173
|
this.eventCenter.listen(EVENT.sizeChanged.name, function (data) {
|
205
174
|
_this.handleSizeChanged(_objectSpread({}, data));
|
206
175
|
});
|
207
|
-
this.eventCenter.listen(EVENT.showCloseButton.name, function (
|
208
|
-
_this.handleCloseButtonTheme(data.style);
|
176
|
+
this.eventCenter.listen(EVENT.showCloseButton.name, function () {
|
209
177
|
_this.changeCloseBtnVisibility(true);
|
210
178
|
});
|
211
179
|
this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
|
@@ -217,22 +185,6 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
217
185
|
this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
|
218
186
|
_this.handleAppHeartBeat();
|
219
187
|
});
|
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
|
-
});
|
236
188
|
}
|
237
189
|
}, {
|
238
190
|
key: "addCapabilityToApiBusManager",
|
@@ -255,26 +207,22 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
255
207
|
}, {
|
256
208
|
key: "handleSizeChanged",
|
257
209
|
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;
|
262
210
|
if (!this.webApp || !this.displayInfo) {
|
263
211
|
return;
|
264
212
|
}
|
265
|
-
var cashier = document.getElementById(
|
266
|
-
if (
|
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;
|
267
215
|
cashier.style.height = "".concat(data.height, "px");
|
268
216
|
this.webApp.style.opacity = '1';
|
269
217
|
if (this.displayInfo.type === DisplayTypeEnum.popup) {
|
270
218
|
if (this.displayInfo.platform === 'desktop') {
|
271
219
|
if (data.width) cashier.style.width = "".concat(data.width, "px");
|
272
|
-
cashier.classList.add("".concat(
|
220
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.displayInfo.platform, "-animation"));
|
273
221
|
this.webApp.style.height = "".concat(data.height, "px");
|
274
222
|
}
|
275
223
|
if (this.displayInfo.platform === 'mobile') {
|
276
|
-
cashier.classList.add("".concat(
|
277
|
-
var animationStyleId = "".concat(
|
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");
|
278
226
|
var animationStyle = document.getElementById(animationStyleId);
|
279
227
|
if (animationStyle) animationStyle === null || animationStyle === void 0 || animationStyle.remove();
|
280
228
|
|
@@ -293,50 +241,6 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
293
241
|
this.webApp.style.height = "".concat(data.height, "px");
|
294
242
|
}
|
295
243
|
}
|
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
|
-
}
|
340
244
|
}, {
|
341
245
|
key: "handleAppHeartBeat",
|
342
246
|
value: function handleAppHeartBeat() {
|
@@ -394,63 +298,6 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
394
298
|
closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_MASK_BLOCK_ID, "-hidden"));
|
395
299
|
}
|
396
300
|
}
|
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
|
-
}
|
454
301
|
}]);
|
455
302
|
return ContainerService;
|
456
303
|
}();
|
@@ -1,20 +1,17 @@
|
|
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
|
-
};
|
10
2
|
/**
|
11
3
|
* @author 谦彧 <zhangmian.zm@alipay.com>
|
12
4
|
* @date 2024/9/22
|
13
5
|
*/
|
14
6
|
export declare class PopupManager {
|
15
7
|
private popupUrlQuery;
|
16
|
-
popupApp
|
8
|
+
private popupApp;
|
17
9
|
setPopupUrlQuery(queryParams: string): void;
|
18
|
-
popup(data:
|
10
|
+
popup(data: {
|
11
|
+
url: string;
|
12
|
+
widthPadding: number;
|
13
|
+
heightPadding: number;
|
14
|
+
platform: PlatformEnum;
|
15
|
+
}): Promise<void>;
|
19
16
|
pop(): void;
|
20
17
|
}
|
@@ -53,9 +53,7 @@ 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
|
57
|
-
showCloseOnLoading: data.showCloseOnLoading,
|
58
|
-
onCloseOnLoading: data.onCloseOnLoading
|
56
|
+
loadingConfig: undefined
|
59
57
|
});
|
60
58
|
case 11:
|
61
59
|
this.popupApp = _context.sent;
|
@@ -109,7 +109,6 @@ 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') {}
|
113
112
|
if (!this.checkEventCompliant(_eventPayload)) {
|
114
113
|
return;
|
115
114
|
}
|
@@ -89,9 +89,7 @@ _defineProperty(LogComplianceExtendKeys, "complianceExtParams", {
|
|
89
89
|
// M 数字类型
|
90
90
|
timeCost: 'M',
|
91
91
|
pageLoadProgress: 'M',
|
92
|
-
fsDuration: 'M'
|
93
|
-
// 由于部分logerror参数是msg
|
94
|
-
msg: 'C'
|
92
|
+
fsDuration: 'M'
|
95
93
|
});
|
96
94
|
export var KEYS = {
|
97
95
|
EVENT_SDK_ON_ABNORMAL_EVENT_NAME: {
|
@@ -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, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
16
|
+
import { appId, device, fomatGetwayError, get, hostSignMap, isPC, lightSandboxMap, queryParse, requestHost, safeJson, sdkVersion, sofaId, tntInstId } from "./deps";
|
17
17
|
|
18
18
|
/**
|
19
19
|
* @author congle.zzq <congle.zzq@alipay.com>
|
@@ -94,7 +94,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
94
94
|
time: Date.now() - startTime,
|
95
95
|
success: false,
|
96
96
|
code: errorCode,
|
97
|
-
|
97
|
+
msg: errorMessage,
|
98
98
|
traceId: traceId
|
99
99
|
});
|
100
100
|
console.log('[DEBUG] handleGetWayError error', {
|
@@ -115,7 +115,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
115
115
|
time: Date.now() - startTime,
|
116
116
|
success: true,
|
117
117
|
code: 'SUCCESS',
|
118
|
-
|
118
|
+
msg: '',
|
119
119
|
traceId: traceId
|
120
120
|
});
|
121
121
|
console.log('[DEBUG] request completed', resData);
|
@@ -139,7 +139,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
139
139
|
time: Date.now() - startTime,
|
140
140
|
success: false,
|
141
141
|
code: _errorCode,
|
142
|
-
|
142
|
+
msg: JSON.stringify((_error === null || _error === void 0 ? void 0 : _error.message) || _context.t0)
|
143
143
|
});
|
144
144
|
console.log('[DEBUG] request error 2', {
|
145
145
|
success: false,
|
@@ -151,8 +151,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
151
151
|
success: false,
|
152
152
|
errorCode: _errorCode,
|
153
153
|
traceId: traceId,
|
154
|
-
|
155
|
-
errorMessage: _error === null || _error === void 0 ? void 0 : _error.errorMessage
|
154
|
+
errorMessage: _error === null || _error === void 0 ? void 0 : _error.message
|
156
155
|
}));
|
157
156
|
case 43:
|
158
157
|
case "end":
|
@@ -170,7 +169,7 @@ export var RequesterService = /*#__PURE__*/function () {
|
|
170
169
|
value: function getEnvInfo(options) {
|
171
170
|
var _options$envInfo;
|
172
171
|
var envInfo = _objectSpread(_objectSpread({
|
173
|
-
terminalType:
|
172
|
+
terminalType: isPC() ? 'WEB' : 'WAP',
|
174
173
|
browserInfo: {
|
175
174
|
browserJavaScriptEnabled: true,
|
176
175
|
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
|
7
|
+
static preloadWebApp(productScene: ProductSceneEnum, paymentMethodCategoryType: PaymentMethodCategoryTypeEnum, environment?: string): 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): {
|
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
|
11
|
+
import { getWebAppUrl } 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,13 +22,12 @@ 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;
|
26
25
|
try {
|
27
26
|
if (this.isWebAppPreloaded) {
|
28
27
|
console.log('[web-sdk] web app already preloaded');
|
29
28
|
return;
|
30
29
|
}
|
31
|
-
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment
|
30
|
+
var _this$buildWebAppPrel = this.buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment),
|
32
31
|
preloadUrl = _this$buildWebAppPrel.preloadUrl,
|
33
32
|
containerId = _this$buildWebAppPrel.containerId;
|
34
33
|
var preloadIframe = createPreloadIframe(containerId);
|
@@ -90,7 +89,6 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
90
89
|
}, {
|
91
90
|
key: "buildWebAppPreloadUrl",
|
92
91
|
value: function buildWebAppPreloadUrl(productScene, paymentMethodCategoryType, environment) {
|
93
|
-
var useV2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
94
92
|
var productSceneVersion = productScene === ProductSceneEnum.EASY_PAY ? '2.0' : '1.0';
|
95
93
|
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(productScene);
|
96
94
|
if (previousProductInfo) {
|
@@ -103,16 +101,14 @@ var PreloadHelper = /*#__PURE__*/function () {
|
|
103
101
|
webAppVersion: ''
|
104
102
|
};
|
105
103
|
sdkMetaData.webAppVersion = getWebAppVersion(sdkMetaData);
|
106
|
-
var
|
104
|
+
var preloadUrl = getWebAppUrl({
|
107
105
|
environment: environment,
|
108
106
|
sdkMetaData: sdkMetaData,
|
109
107
|
paymentMethodCategoryType: paymentMethodCategoryType,
|
110
108
|
isPreload: true,
|
111
|
-
productScene: productScene,
|
112
109
|
productSceneVersion: productSceneVersion,
|
113
110
|
query: undefined
|
114
|
-
};
|
115
|
-
var preloadUrl = useV2 ? getWebAppV2Url(preloadUrlParams) : getWebAppUrl(preloadUrlParams);
|
111
|
+
});
|
116
112
|
return {
|
117
113
|
preloadUrl: preloadUrl,
|
118
114
|
containerId: containerId
|
@@ -69,42 +69,26 @@ 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
|
-
};
|
88
72
|
var callSchemeUrl = function callSchemeUrl() {
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
}
|
73
|
+
callAppLib.open({
|
74
|
+
scheme: payload.schemeUrl,
|
75
|
+
fallback: function fallback() {
|
76
|
+
failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
|
77
|
+
if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
|
78
|
+
successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
|
79
|
+
window.location.href = payload.url;
|
80
|
+
}
|
81
|
+
});
|
105
82
|
};
|
106
83
|
if (payload.applinkUrl) {
|
107
|
-
|
84
|
+
callAppLib.open({
|
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
|
+
});
|
108
92
|
} else if (payload.schemeUrl) {
|
109
93
|
callSchemeUrl();
|
110
94
|
}
|
@@ -132,7 +116,7 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
|
|
132
116
|
};
|
133
117
|
var failCallback = function failCallback(payload, type, url, serviceProvider) {
|
134
118
|
serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
|
135
|
-
code: eventCodeEnum.
|
119
|
+
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
136
120
|
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)
|
137
121
|
});
|
138
122
|
serviceProvider.getService('Log').logInfo({
|