@alipay/ams-checkout 0.0.1758607092-dev.0 → 0.0.1758783821-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/popupWindow.style.d.ts +18 -9
- package/esm/component/popupWindow.style.js +21 -11
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +37 -0
- package/esm/constant/index.js +38 -0
- package/esm/core/component/element/EventCenter/index.d.ts +29 -0
- package/esm/core/component/element/EventCenter/index.js +141 -0
- package/esm/core/component/element/elementContainerService/containerService.js +3 -2
- package/esm/core/component/element/elementController/index.d.ts +28 -2
- package/esm/core/component/element/elementController/index.js +453 -190
- package/esm/core/component/element/elementProcessor/addressProcessor.js +3 -3
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +20 -14
- package/esm/core/component/element/index.d.ts +9 -1
- package/esm/core/component/element/index.js +10 -2
- package/esm/core/component/element/type.d.ts +37 -4
- package/esm/core/component/element/type.js +45 -2
- package/esm/core/component/element/util.d.ts +17 -4
- package/esm/core/component/element/util.js +45 -6
- package/esm/foundation/service/container/index.js +10 -35
- package/esm/foundation/service/container/popup.d.ts +11 -0
- package/esm/foundation/service/container/popup.js +23 -2
- package/esm/foundation/service/log/keys.js +2 -0
- package/esm/foundation/service/requester/requester.js +2 -3
- package/esm/types/index.d.ts +5 -1
- package/esm/util/spm-map.d.ts +2 -0
- package/esm/util/spm-map.js +2 -1
- package/package.json +1 -1
|
@@ -1,14 +1,23 @@
|
|
|
1
|
+
type CreateModalProps = {
|
|
2
|
+
device: any;
|
|
3
|
+
url: string;
|
|
4
|
+
widthPadding?: number;
|
|
5
|
+
loadingConfig?: {
|
|
6
|
+
theme?: string;
|
|
7
|
+
backgroundPrimary?: string;
|
|
8
|
+
};
|
|
9
|
+
showCloseOnLoading: boolean;
|
|
10
|
+
onCloseOnLoading: () => void;
|
|
11
|
+
textDirection: 'ltr' | 'rtl';
|
|
12
|
+
};
|
|
1
13
|
export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
|
|
2
14
|
export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
|
|
3
15
|
export declare const removePopupLoading: (isShowMockup?: boolean) => void;
|
|
4
16
|
export declare const insertStyleSheet: () => void;
|
|
5
|
-
export declare function createCloseIcon(onClose
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
loadingConfig: any;
|
|
11
|
-
showCloseOnLoading: any;
|
|
12
|
-
onCloseOnLoading: any;
|
|
13
|
-
}) => Promise<HTMLIFrameElement>;
|
|
17
|
+
export declare function createCloseIcon({ onClose, textDirection, }: {
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
textDirection: 'ltr' | 'rtl';
|
|
20
|
+
}): HTMLDivElement;
|
|
21
|
+
export declare const createModal: ({ device, url, loadingConfig, showCloseOnLoading, onCloseOnLoading, textDirection, }: CreateModalProps) => Promise<HTMLIFrameElement>;
|
|
14
22
|
export declare const destroyModal: () => void;
|
|
23
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AMSPOPUP_PREFIX, ANIMATION_TIME, MOCKUP_ID, POPUPLOADING_ID } from "../constant";
|
|
2
2
|
import { getDesignFontSize } from "../util";
|
|
3
|
-
|
|
4
3
|
// CSS样式字符串
|
|
5
4
|
var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n .").concat(AMSPOPUP_PREFIX, "modal-mobile{\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n bottom: 0;\n left: 0%;\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "-drawer-enter {\n animation: slideIn ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideIn {\n from {\n transform: translateY(100%); /* \u6ED1\u5165\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 0 */\n }\n to {\n transform: translateY(0); /* \u6ED1\u5165\u7ED3\u675F\u65F6\u5728\u539F\u4F4D\u7F6E */\n opacity: 1; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 1 */\n }\n }\n\n /* \u62BD\u5C49\u4ECE\u5E95\u90E8\u6ED1\u51FA */\n .").concat(AMSPOPUP_PREFIX, "-drawer-exit {\n animation: slideOut ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideOut {\n from {\n transform: translateY(0); /* \u6ED1\u51FA\u65F6\u4ECE\u5F53\u524D\u4F4D\u7F6E\u5F00\u59CB */\n opacity: 1; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 1 */\n }\n to {\n transform: translateY(100%); /* \u6ED1\u51FA\u7ED3\u675F\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 0 */\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n\n.ams-component-popup-loading {\n width: 0.8em;\n height:0.8em;\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-popup-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-popup-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-popup-loading .line div:before,\n.ams-component-popup-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: black;\n border-radius: 5.3px;\n}\n.ams-component-popup-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-popup-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n.ams-component-popup-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-popup-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n");
|
|
6
5
|
var getCurrentTheme = function getCurrentTheme() {
|
|
@@ -47,10 +46,16 @@ export var insertStyleSheet = function insertStyleSheet() {
|
|
|
47
46
|
style.innerHTML = modalStyles;
|
|
48
47
|
document.head.appendChild(style);
|
|
49
48
|
};
|
|
50
|
-
export function createCloseIcon(
|
|
49
|
+
export function createCloseIcon(_ref) {
|
|
50
|
+
var onClose = _ref.onClose,
|
|
51
|
+
textDirection = _ref.textDirection;
|
|
51
52
|
var closeIcon = document.createElement('div');
|
|
52
53
|
closeIcon.style.position = 'absolute';
|
|
53
|
-
|
|
54
|
+
if (textDirection === 'rtl') {
|
|
55
|
+
closeIcon.style.left = '16px';
|
|
56
|
+
} else {
|
|
57
|
+
closeIcon.style.right = '16px';
|
|
58
|
+
}
|
|
54
59
|
closeIcon.style.top = '23px';
|
|
55
60
|
closeIcon.style.cursor = 'pointer';
|
|
56
61
|
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
@@ -71,13 +76,14 @@ export function createCloseIcon(onClose) {
|
|
|
71
76
|
var modalDevice = 'desktop';
|
|
72
77
|
// 插入弹窗
|
|
73
78
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
-
export var createModal = function createModal(
|
|
75
|
-
var device =
|
|
76
|
-
url =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
export var createModal = function createModal(_ref2) {
|
|
80
|
+
var device = _ref2.device,
|
|
81
|
+
url = _ref2.url,
|
|
82
|
+
loadingConfig = _ref2.loadingConfig,
|
|
83
|
+
showCloseOnLoading = _ref2.showCloseOnLoading,
|
|
84
|
+
onCloseOnLoading = _ref2.onCloseOnLoading,
|
|
85
|
+
_ref2$textDirection = _ref2.textDirection,
|
|
86
|
+
textDirection = _ref2$textDirection === void 0 ? 'ltr' : _ref2$textDirection;
|
|
81
87
|
return new Promise(function (resolve, reject) {
|
|
82
88
|
try {
|
|
83
89
|
modalDevice = device;
|
|
@@ -95,6 +101,7 @@ export var createModal = function createModal(_ref) {
|
|
|
95
101
|
modal.style.height = '80vh';
|
|
96
102
|
modal.style.borderRadius = '12px 12px 0 0';
|
|
97
103
|
}
|
|
104
|
+
modal.setAttribute('dir', textDirection);
|
|
98
105
|
var iframe = document.createElement('iframe');
|
|
99
106
|
iframe.src = url; // 替换为实际的 URL 地址
|
|
100
107
|
iframe.style.border = 'none';
|
|
@@ -113,7 +120,10 @@ export var createModal = function createModal(_ref) {
|
|
|
113
120
|
|
|
114
121
|
// 弹窗渲染loading时关闭按钮逻辑
|
|
115
122
|
if (showCloseOnLoading) {
|
|
116
|
-
var closeIcon = createCloseIcon(
|
|
123
|
+
var closeIcon = createCloseIcon({
|
|
124
|
+
onClose: onCloseOnLoading,
|
|
125
|
+
textDirection: textDirection
|
|
126
|
+
});
|
|
117
127
|
modal.appendChild(closeIcon);
|
|
118
128
|
iframe.addEventListener('load', function () {
|
|
119
129
|
modal.removeChild(closeIcon);
|
package/esm/config/index.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export declare const sdkVersion: string;
|
|
|
6
6
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
|
7
7
|
* TODO 这里考虑直接换成packagejson.version
|
|
8
8
|
*/
|
|
9
|
-
export declare const AMSCheckoutAppVersion = "1.
|
|
10
|
-
export declare const AMSAutoDebitAppVersion = "1.
|
|
11
|
-
export declare const AMSEasyPayAppVersion = "1.
|
|
12
|
-
export declare const AMSCashierPaymentAppVersion = "1.
|
|
13
|
-
export declare const AMSVaultingAppVersion = "1.
|
|
14
|
-
export declare const AMSPaymentElementAppVersion = "1.
|
|
15
|
-
export declare const ADDRESSElementAppVersion = "1.
|
|
9
|
+
export declare const AMSCheckoutAppVersion = "1.45.0";
|
|
10
|
+
export declare const AMSAutoDebitAppVersion = "1.45.0";
|
|
11
|
+
export declare const AMSEasyPayAppVersion = "1.45.0";
|
|
12
|
+
export declare const AMSCashierPaymentAppVersion = "1.45.0";
|
|
13
|
+
export declare const AMSVaultingAppVersion = "1.45.0";
|
|
14
|
+
export declare const AMSPaymentElementAppVersion = "1.45.0";
|
|
15
|
+
export declare const ADDRESSElementAppVersion = "1.45.0";
|
package/esm/config/index.js
CHANGED
|
@@ -36,10 +36,10 @@ export var sdkVersion = json.version;
|
|
|
36
36
|
* @description: 目前应用层分为v1和v2,会存在两个应用版本号不是同步发布的情况。所以需要把默认的应用版本号配置抽离出来。
|
|
37
37
|
* TODO 这里考虑直接换成packagejson.version
|
|
38
38
|
*/
|
|
39
|
-
export var AMSCheckoutAppVersion = '1.
|
|
40
|
-
export var AMSAutoDebitAppVersion = '1.
|
|
41
|
-
export var AMSEasyPayAppVersion = '1.
|
|
42
|
-
export var AMSCashierPaymentAppVersion = '1.
|
|
43
|
-
export var AMSVaultingAppVersion = '1.
|
|
44
|
-
export var AMSPaymentElementAppVersion = '1.
|
|
45
|
-
export var ADDRESSElementAppVersion = '1.
|
|
39
|
+
export var AMSCheckoutAppVersion = '1.45.0'; // 兜底版本号
|
|
40
|
+
export var AMSAutoDebitAppVersion = '1.45.0'; // 代扣
|
|
41
|
+
export var AMSEasyPayAppVersion = '1.45.0'; // easypay
|
|
42
|
+
export var AMSCashierPaymentAppVersion = '1.45.0'; // 收银台(卡、apm)
|
|
43
|
+
export var AMSVaultingAppVersion = '1.45.0'; // 绑卡
|
|
44
|
+
export var AMSPaymentElementAppVersion = '1.45.0'; // payment element
|
|
45
|
+
export var ADDRESSElementAppVersion = '1.45.0'; // address element
|
package/esm/constant/index.d.ts
CHANGED
|
@@ -82,6 +82,40 @@ export declare const ERRORMESSAGE: {
|
|
|
82
82
|
code: eventCodeEnum;
|
|
83
83
|
message: string;
|
|
84
84
|
};
|
|
85
|
+
PARAM_INVALID: {
|
|
86
|
+
code: string;
|
|
87
|
+
message: string;
|
|
88
|
+
};
|
|
89
|
+
UI_STATE_ERROR: {
|
|
90
|
+
code: string;
|
|
91
|
+
message: string;
|
|
92
|
+
};
|
|
93
|
+
CONTAINER_NOT_LOADED: {
|
|
94
|
+
code: string;
|
|
95
|
+
message: string;
|
|
96
|
+
};
|
|
97
|
+
INITALIZE_TIMEOUT: {
|
|
98
|
+
API: {
|
|
99
|
+
code: string;
|
|
100
|
+
message: string;
|
|
101
|
+
};
|
|
102
|
+
WEB: {
|
|
103
|
+
code: string;
|
|
104
|
+
message: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
ERR_DATA_STRUCT_UNRECOGNIZED: {
|
|
108
|
+
code: string;
|
|
109
|
+
status: string;
|
|
110
|
+
};
|
|
111
|
+
INQUIRY_PAYMENT_SESSION_FAILED: {
|
|
112
|
+
code: string;
|
|
113
|
+
message: string;
|
|
114
|
+
};
|
|
115
|
+
UNKNOWN_EXCEPTION: {
|
|
116
|
+
code: string;
|
|
117
|
+
message: string;
|
|
118
|
+
};
|
|
85
119
|
/**
|
|
86
120
|
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
|
87
121
|
*/
|
|
@@ -249,6 +283,9 @@ export declare const EVENT: {
|
|
|
249
283
|
messageForward: {
|
|
250
284
|
name: string;
|
|
251
285
|
};
|
|
286
|
+
submitPromiseCallback: {
|
|
287
|
+
name: string;
|
|
288
|
+
};
|
|
252
289
|
validateFieldsResult: {
|
|
253
290
|
name: string;
|
|
254
291
|
forwardName: string;
|
package/esm/constant/index.js
CHANGED
|
@@ -82,6 +82,40 @@ export var ERRORMESSAGE = {
|
|
|
82
82
|
code: eventCodeEnum.SDK_LAUNCH_PAYMENT_APP_ERROR,
|
|
83
83
|
message: 'Component not created or current browser compatibility issue, not supported'
|
|
84
84
|
},
|
|
85
|
+
PARAM_INVALID: {
|
|
86
|
+
code: 'PARAM_INVALID',
|
|
87
|
+
message: '请求异常,交易无法发起。'
|
|
88
|
+
},
|
|
89
|
+
UI_STATE_ERROR: {
|
|
90
|
+
code: 'UI_STATE_ERROR',
|
|
91
|
+
message: '请求异常,交易无法发起。'
|
|
92
|
+
},
|
|
93
|
+
CONTAINER_NOT_LOADED: {
|
|
94
|
+
code: 'CONTAINER_NOT_LOADED',
|
|
95
|
+
message: '请求异常,交易无法发起。'
|
|
96
|
+
},
|
|
97
|
+
INITALIZE_TIMEOUT: {
|
|
98
|
+
API: {
|
|
99
|
+
code: 'INITALIZE_API_TIMEOUT',
|
|
100
|
+
message: '请求异常,交易无法发起。'
|
|
101
|
+
},
|
|
102
|
+
WEB: {
|
|
103
|
+
code: 'INITALIZE_WEB_TIMEOUT',
|
|
104
|
+
message: '请求异常,交易无法发起。'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
ERR_DATA_STRUCT_UNRECOGNIZED: {
|
|
108
|
+
code: 'ERR_DATA_STRUCT_UNRECOGNIZED',
|
|
109
|
+
status: 'FAIL'
|
|
110
|
+
},
|
|
111
|
+
INQUIRY_PAYMENT_SESSION_FAILED: {
|
|
112
|
+
code: 'INQUIRY_PAYMENT_SESSION_FAILED',
|
|
113
|
+
message: '订单状态异常。请检查付款情况并联系商户'
|
|
114
|
+
},
|
|
115
|
+
UNKNOWN_EXCEPTION: {
|
|
116
|
+
code: 'UNKNOWN_EXCEPTION',
|
|
117
|
+
message: '未知异常。请检查付款情况并联系商户'
|
|
118
|
+
},
|
|
85
119
|
/**
|
|
86
120
|
@deprecated 已废弃 请使用SDK_LAUNCH_PAYMENT_APP_ERROR
|
|
87
121
|
*/
|
|
@@ -251,6 +285,10 @@ export var EVENT = {
|
|
|
251
285
|
messageForward: {
|
|
252
286
|
name: 'onMessageForward'
|
|
253
287
|
},
|
|
288
|
+
// Element支付完成后事件
|
|
289
|
+
submitPromiseCallback: {
|
|
290
|
+
name: 'submitPromiseCallback'
|
|
291
|
+
},
|
|
254
292
|
validateFieldsResult: {
|
|
255
293
|
name: 'validateFieldsResult',
|
|
256
294
|
forwardName: 'validateFieldsResultForward',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LogService } from '../../../../foundation/service/log';
|
|
2
|
+
export declare class EventCenter {
|
|
3
|
+
private activeEvents;
|
|
4
|
+
private heartbeatIntervalId;
|
|
5
|
+
private readonly HEARTBEAT_INTERVAL;
|
|
6
|
+
private uniqueId;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor({ logger }: {
|
|
9
|
+
logger: LogService;
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* 注册事件
|
|
13
|
+
* @param {string} functionName 函数名称
|
|
14
|
+
* @returns {string} 返回事件起始ID
|
|
15
|
+
*/
|
|
16
|
+
registerEvent(functionName: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* 结束事件
|
|
19
|
+
* @param startId 事件起始ID
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
endEvent(startId: string, extra?: any): void;
|
|
23
|
+
private startHeartbeat;
|
|
24
|
+
private stopHeartbeat;
|
|
25
|
+
private sendHeartbeat;
|
|
26
|
+
private sendLog;
|
|
27
|
+
private buildId;
|
|
28
|
+
private buildIdFromStart;
|
|
29
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
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); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
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); }
|
|
16
|
+
import { ELEMENT_SPM_MAP } from "../../../../util/spm-map";
|
|
17
|
+
export var EventCenter = /*#__PURE__*/function () {
|
|
18
|
+
// 日志服务实例
|
|
19
|
+
|
|
20
|
+
function EventCenter(_ref) {
|
|
21
|
+
var logger = _ref.logger;
|
|
22
|
+
_classCallCheck(this, EventCenter);
|
|
23
|
+
_defineProperty(this, "activeEvents", new Map());
|
|
24
|
+
// key: eventId, value: startTime
|
|
25
|
+
_defineProperty(this, "heartbeatIntervalId", null);
|
|
26
|
+
// 心跳定时器ID
|
|
27
|
+
_defineProperty(this, "HEARTBEAT_INTERVAL", 5000);
|
|
28
|
+
// 心跳间隔时间(毫秒)
|
|
29
|
+
_defineProperty(this, "uniqueId", 0);
|
|
30
|
+
// 唯一ID 自增
|
|
31
|
+
_defineProperty(this, "logger", void 0);
|
|
32
|
+
this.logger = logger;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 注册事件
|
|
37
|
+
* @param {string} functionName 函数名称
|
|
38
|
+
* @returns {string} 返回事件起始ID
|
|
39
|
+
*/
|
|
40
|
+
_createClass(EventCenter, [{
|
|
41
|
+
key: "registerEvent",
|
|
42
|
+
value: function registerEvent(functionName) {
|
|
43
|
+
// 构建事件起始ID
|
|
44
|
+
var startId = this.buildId(functionName, 'start');
|
|
45
|
+
// 将当前时间戳设置为活动事件的起始时间
|
|
46
|
+
this.activeEvents.set(startId, Date.now());
|
|
47
|
+
|
|
48
|
+
// 启动心跳检测
|
|
49
|
+
this.startHeartbeat();
|
|
50
|
+
// 发送日志,记录事件起始信息
|
|
51
|
+
this.sendLog('startEvent', {
|
|
52
|
+
eventName: startId
|
|
53
|
+
});
|
|
54
|
+
return startId;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 结束事件
|
|
59
|
+
* @param startId 事件起始ID
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
}, {
|
|
63
|
+
key: "endEvent",
|
|
64
|
+
value: function endEvent(startId, extra) {
|
|
65
|
+
// 如果活动事件中不存在该起始ID,则直接返回
|
|
66
|
+
if (!this.activeEvents.has(startId)) return;
|
|
67
|
+
// 获取起始时间
|
|
68
|
+
var startTime = this.activeEvents.get(startId);
|
|
69
|
+
// 从活动事件中删除该起始ID
|
|
70
|
+
this.activeEvents.delete(startId);
|
|
71
|
+
|
|
72
|
+
// 发送日志,记录事件结束信息
|
|
73
|
+
this.sendLog('endEvent', _objectSpread({
|
|
74
|
+
eventName: this.buildIdFromStart(startId, 'end'),
|
|
75
|
+
startTime: startTime,
|
|
76
|
+
endTime: Date.now()
|
|
77
|
+
}, extra ? {
|
|
78
|
+
msg: JSON.stringify(extra)
|
|
79
|
+
} : null));
|
|
80
|
+
|
|
81
|
+
// 如果活动事件数量为0,则停止心跳
|
|
82
|
+
if (this.activeEvents.size === 0) this.stopHeartbeat();
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "startHeartbeat",
|
|
86
|
+
value: function startHeartbeat() {
|
|
87
|
+
var _this = this;
|
|
88
|
+
if (this.heartbeatIntervalId) return;
|
|
89
|
+
this.heartbeatIntervalId = setInterval(function () {
|
|
90
|
+
if (_this.activeEvents.size === 0) {
|
|
91
|
+
_this.stopHeartbeat();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
_this.sendHeartbeat();
|
|
95
|
+
}, this.HEARTBEAT_INTERVAL);
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "stopHeartbeat",
|
|
99
|
+
value: function stopHeartbeat() {
|
|
100
|
+
if (this.heartbeatIntervalId === null) return;
|
|
101
|
+
clearInterval(this.heartbeatIntervalId);
|
|
102
|
+
this.heartbeatIntervalId = null;
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "sendHeartbeat",
|
|
106
|
+
value: function sendHeartbeat() {
|
|
107
|
+
var actionNames = Array.from(this.activeEvents.entries()).map(function (_ref2) {
|
|
108
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
109
|
+
id = _ref3[0],
|
|
110
|
+
startTime = _ref3[1];
|
|
111
|
+
return {
|
|
112
|
+
eventName: id,
|
|
113
|
+
startTime: startTime
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
this.sendLog('heartbeat', {
|
|
117
|
+
actionNames: JSON.stringify(actionNames)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "sendLog",
|
|
122
|
+
value: function sendLog(type, payload) {
|
|
123
|
+
this.logger.logInfo({
|
|
124
|
+
title: ELEMENT_SPM_MAP.sdk_element_handleHeartBeat
|
|
125
|
+
}, _objectSpread({
|
|
126
|
+
actionName: type
|
|
127
|
+
}, payload));
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "buildId",
|
|
131
|
+
value: function buildId(fn, suffix) {
|
|
132
|
+
return "".concat(fn, "_").concat(++this.uniqueId, "_").concat(suffix);
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "buildIdFromStart",
|
|
136
|
+
value: function buildIdFromStart(startId, suffix) {
|
|
137
|
+
return startId.replace(/_start$/, "_".concat(suffix));
|
|
138
|
+
}
|
|
139
|
+
}]);
|
|
140
|
+
return EventCenter;
|
|
141
|
+
}();
|
|
@@ -19,7 +19,7 @@ export var IContainerStatus = /*#__PURE__*/function (IContainerStatus) {
|
|
|
19
19
|
}({});
|
|
20
20
|
export var ContainerController = /*#__PURE__*/function () {
|
|
21
21
|
function ContainerController(_ref) {
|
|
22
|
-
var _options$debugProps;
|
|
22
|
+
var _options$debugProps, _options$debugProps2;
|
|
23
23
|
var type = _ref.type,
|
|
24
24
|
instanceId = _ref.instanceId,
|
|
25
25
|
selector = _ref.selector,
|
|
@@ -41,6 +41,7 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
|
41
41
|
sdkVersion: '',
|
|
42
42
|
webAppVersion: ''
|
|
43
43
|
});
|
|
44
|
+
var iframesSrcLink = options !== null && options !== void 0 && (_options$debugProps = options.debugProps) !== null && _options$debugProps !== void 0 && _options$debugProps.isDebug ? (options === null || options === void 0 || (_options$debugProps2 = options.debugProps) === null || _options$debugProps2 === void 0 ? void 0 : _options$debugProps2.localLink) || '' : '';
|
|
44
45
|
this.containerElement = this.containerService.load({
|
|
45
46
|
type: DisplayTypeEnum.inline,
|
|
46
47
|
platform: isElementPad() ? PlatformEnum.desktop : isElementPC() ? PlatformEnum.desktop : PlatformEnum.mobile,
|
|
@@ -51,7 +52,7 @@ export var ContainerController = /*#__PURE__*/function () {
|
|
|
51
52
|
display: 'block'
|
|
52
53
|
}
|
|
53
54
|
}, processor.generateIframeSrc({
|
|
54
|
-
link:
|
|
55
|
+
link: iframesSrcLink,
|
|
55
56
|
instanceId: this.instanceId
|
|
56
57
|
}));
|
|
57
58
|
this.eventService = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddressMountOptions, IElementOptions, LinkAuthMountOptions, PaymentMountOptions } from '../type';
|
|
1
|
+
import { AddressMountOptions, IElementOptions, IMerchantResponse, LinkAuthMountOptions, PaymentMountOptions } from '../type';
|
|
2
2
|
declare class ElementController {
|
|
3
3
|
private options;
|
|
4
4
|
private elementContainer;
|
|
@@ -8,16 +8,42 @@ declare class ElementController {
|
|
|
8
8
|
private initTimeout;
|
|
9
9
|
private elementContainerService;
|
|
10
10
|
private onStatusChangeCallback;
|
|
11
|
+
private submitPayPromise;
|
|
12
|
+
private elementEventCenter;
|
|
11
13
|
constructor(options: IElementOptions);
|
|
12
14
|
private initService;
|
|
13
15
|
private initElementProcessors;
|
|
14
16
|
private onEventCallback;
|
|
17
|
+
/**
|
|
18
|
+
* 处理初始化错误的方法
|
|
19
|
+
*/
|
|
20
|
+
private handleInitializationError;
|
|
21
|
+
private handleMountError;
|
|
22
|
+
private clearAndSetInitTimeout;
|
|
23
|
+
private setInitTimeout;
|
|
24
|
+
private initializeAndMountProcessor;
|
|
25
|
+
private handleStartBizFlowError;
|
|
15
26
|
mount(renderOptions: LinkAuthMountOptions | AddressMountOptions | PaymentMountOptions, sdkSelector: string): any;
|
|
16
27
|
private onValidateFunc;
|
|
17
|
-
|
|
28
|
+
private onValidateAndSubmitPay;
|
|
29
|
+
/**
|
|
30
|
+
* 25/09/08 新增商户主动校验api
|
|
31
|
+
* @returns {Promise<{isValid: boolean}>}
|
|
32
|
+
*/
|
|
33
|
+
validateFields(): Promise<{
|
|
34
|
+
isValid: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
submitPayment(): Promise<IMerchantResponse | {
|
|
37
|
+
error: {
|
|
38
|
+
code: string;
|
|
39
|
+
message: string;
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
18
42
|
private changeLoading;
|
|
19
43
|
private addEventListener;
|
|
20
44
|
private sendRequestAndWaitWebLaunch;
|
|
45
|
+
private getErrorFromResponse;
|
|
46
|
+
private areAllContainersReady;
|
|
21
47
|
private sendReady;
|
|
22
48
|
updatePayment(paymentSessionData: any): Promise<unknown>;
|
|
23
49
|
private destroyHandle;
|