@alipay/ams-checkout 0.0.1755258862-dev.7 → 0.0.1756796178-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 +3 -1
- package/esm/component/channel.js +26 -62
- package/esm/component/component.inline.style.js +2 -2
- package/esm/component/popupWindow.style.d.ts +4 -1
- package/esm/component/popupWindow.style.js +37 -2
- 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 +41 -2
- package/esm/constant/index.js +43 -5
- package/esm/core/component/ckp/index.d.ts +2 -0
- package/esm/core/component/ckp/index.js +41 -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 +493 -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 +74 -34
- package/esm/core/component/element/type.js +20 -12
- 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 -53
- 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 +271 -169
- 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 +14 -3
- package/esm/foundation/service/container/index.js +178 -25
- package/esm/foundation/service/container/popup.d.ts +10 -7
- package/esm/foundation/service/container/popup.js +3 -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 +20 -109
- package/esm/foundation/utils/preload_helper.d.ts +2 -2
- package/esm/foundation/utils/preload_helper.js +8 -6
- 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 +8 -5
- package/esm/index.js +103 -53
- 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 +49 -45
- package/esm/plugin/type.d.ts +1 -1
- package/esm/request/index.js +2 -2
- package/esm/types/index.d.ts +37 -3
- package/esm/types/index.js +10 -2
- package/esm/util/index.d.ts +12 -1
- package/esm/util/index.js +39 -3
- package/esm/util/redirect.d.ts +6 -0
- package/esm/util/redirect.js +54 -0
- package/esm/util/spm-map.d.ts +18 -4
- package/esm/util/spm-map.js +20 -6
- 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
@@ -0,0 +1,7 @@
|
|
1
|
+
import { BizFlowStartBehavior, ProductProcessor } from "../..";
|
2
|
+
declare class ElementProcessor implements ProductProcessor {
|
3
|
+
constructor();
|
4
|
+
init(config: any, instanceId: string): any;
|
5
|
+
startBizFlow(): Promise<BizFlowStartBehavior>;
|
6
|
+
}
|
7
|
+
export { ElementProcessor };
|
@@ -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
|
-
|
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
|
+
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 {
|
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
|
}
|
@@ -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
|
-
|
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
|
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 =
|
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
|
-
|
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(
|
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(
|
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(
|
225
|
-
var animationStyleId = "".concat(
|
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
|
-
|
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: {
|