@alipay/ams-checkout 0.0.1762138227-dev.7 → 0.0.1762138227-dev.9
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/{ams-checkout.min.js → ams-checkout.js} +1 -1
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +3 -2
- package/esm/foundation/product-processor/easysafepay/index.js +3 -2
- package/esm/loader/Proxy.js +26 -7
- package/esm/loader/constant.js +2 -2
- package/esm/loader/utils/loadSDK.d.ts +6 -1
- package/esm/loader/utils/loadSDK.js +11 -5
- package/esm/loader/utils/setStartTime.d.ts +12 -0
- package/esm/loader/utils/setStartTime.js +25 -0
- package/esm/util/integrationType.js +0 -3
- package/package.json +2 -2
|
@@ -61,7 +61,7 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
61
61
|
_createClass(PaymentProcessor, [{
|
|
62
62
|
key: "onReady",
|
|
63
63
|
value: function onReady(extraParam) {
|
|
64
|
-
var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5;
|
|
64
|
+
var _this$elementContaine, _this$elementContaine2, _this$elementContaine3, _this$elementContaine4, _this$elementContaine5, _window;
|
|
65
65
|
var paymentContext = this.elementContainer.getPaymentContext();
|
|
66
66
|
this.getLogger().logInfo({
|
|
67
67
|
title: 'sdk_event_renderComponent'
|
|
@@ -82,7 +82,8 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
82
82
|
productSceneVersion: (_this$elementContaine2 = this.elementContainer) === null || _this$elementContaine2 === void 0 ? void 0 : _this$elementContaine2.getPaymentContext().paymentSessionObj.paymentSessionConfig.productSceneVersion,
|
|
83
83
|
trackId: (_this$elementContaine3 = this.elementContainer) === null || _this$elementContaine3 === void 0 ? void 0 : _this$elementContaine3.getPaymentContext().paymentSessionId,
|
|
84
84
|
merchantId: (_this$elementContaine4 = this.elementContainer) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.getPaymentContext()) === null || _this$elementContaine4 === void 0 || (_this$elementContaine4 = _this$elementContaine4.paymentSessionObj) === null || _this$elementContaine4 === void 0 ? void 0 : _this$elementContaine4.clientId,
|
|
85
|
-
paymentMethodType: (_this$elementContaine5 = this.elementContainer) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.getPaymentContext()) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentSessionObj) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentMethodInfoView) === null || _this$elementContaine5 === void 0 ? void 0 : _this$elementContaine5.paymentMethodType
|
|
85
|
+
paymentMethodType: (_this$elementContaine5 = this.elementContainer) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.getPaymentContext()) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentSessionObj) === null || _this$elementContaine5 === void 0 || (_this$elementContaine5 = _this$elementContaine5.paymentMethodInfoView) === null || _this$elementContaine5 === void 0 ? void 0 : _this$elementContaine5.paymentMethodType,
|
|
86
|
+
proxyStartTime: (_window = window) === null || _window === void 0 || (_window = _window._ANTOM_SDK_PROXY_START_TIME) === null || _window === void 0 ? void 0 : _window['AMSElement']
|
|
86
87
|
},
|
|
87
88
|
appearance: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.displayInfo.appearance,
|
|
88
89
|
sessionResult: paymentContext === null || paymentContext === void 0 ? void 0 : paymentContext.paymentSessionObj,
|
|
@@ -194,7 +194,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
|
194
194
|
|
|
195
195
|
// 等请求和 Web启动都Ready之后,发送renderComponent
|
|
196
196
|
Promise.all([this.initSecuritySDK(), this.processQuery(), this.processSubmitPay(), webLaunchPromise]).then(function (_ref) {
|
|
197
|
-
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext3, _this$paymentContext$4;
|
|
197
|
+
var _this$paymentContext, _this$paymentContext2, _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3, _this$paymentContext3, _this$paymentContext$4, _window;
|
|
198
198
|
var _ref2 = _slicedToArray(_ref, 4),
|
|
199
199
|
_initSecurityRes = _ref2[0],
|
|
200
200
|
queryRes = _ref2[1],
|
|
@@ -227,7 +227,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
|
227
227
|
sdkVersion: logMetaData.sdkVersion,
|
|
228
228
|
merchantId: logMetaData.merchantId,
|
|
229
229
|
instanceId: logMetaData.instanceId,
|
|
230
|
-
paymentMethodType: logMetaData.paymentMethodType
|
|
230
|
+
paymentMethodType: logMetaData.paymentMethodType,
|
|
231
|
+
proxyStartTime: (_window = window) === null || _window === void 0 || (_window = _window._ANTOM_SDK_PROXY_START_TIME) === null || _window === void 0 ? void 0 : _window['AMSEasyPay']
|
|
231
232
|
})
|
|
232
233
|
};
|
|
233
234
|
if (queryRes) {
|
package/esm/loader/Proxy.js
CHANGED
|
@@ -20,6 +20,7 @@ import { supportsDefineProperty, supportsProxy } from "./utils/common";
|
|
|
20
20
|
import { setDebugContext } from "./utils/debugger";
|
|
21
21
|
import { loadSdk, newActualInstance } from "./utils/loadSDK";
|
|
22
22
|
import { consoleLogger, logger } from "./utils/logger";
|
|
23
|
+
import { setStartTime } from "./utils/setStartTime";
|
|
23
24
|
|
|
24
25
|
// eslint-disable-next-line
|
|
25
26
|
|
|
@@ -177,9 +178,10 @@ export function createBaseProxy(constructorName) {
|
|
|
177
178
|
}
|
|
178
179
|
});
|
|
179
180
|
this.startTime = Date.now();
|
|
180
|
-
|
|
181
181
|
// 初始化debug参数
|
|
182
182
|
setDebugContext(debugProps);
|
|
183
|
+
// 记录startTime
|
|
184
|
+
setStartTime(constructorName, this.startTime);
|
|
183
185
|
// 创建代理实例
|
|
184
186
|
this.proxyInstance = this.newProxyInstance();
|
|
185
187
|
// 加载sdk并创建真实实例
|
|
@@ -195,28 +197,45 @@ export function createBaseProxy(constructorName) {
|
|
|
195
197
|
key: "loadSDKAndCreateInstance",
|
|
196
198
|
value: function loadSDKAndCreateInstance(constructorName, newProps) {
|
|
197
199
|
var _this2 = this;
|
|
198
|
-
loadSdk().then(function () {
|
|
200
|
+
loadSdk().then(function (_ref) {
|
|
201
|
+
var loadType = _ref.loadType;
|
|
199
202
|
try {
|
|
200
203
|
var actualInstance = newActualInstance(constructorName, newProps);
|
|
201
|
-
|
|
204
|
+
var newActualInstanceDuration = Date.now() - _this2.startTime;
|
|
205
|
+
// 上报newProxy到初始化真实sdk实例花费时间,忽略SDK缓存场景
|
|
202
206
|
logger.logInfo({
|
|
203
|
-
title: '
|
|
207
|
+
title: 'loadSDK_and_create_actual_instance'
|
|
204
208
|
}, {
|
|
205
|
-
|
|
209
|
+
constructorName: constructorName,
|
|
210
|
+
loadDuration: loadType === 'network' ? newActualInstanceDuration : undefined
|
|
206
211
|
});
|
|
212
|
+
// 热更新全流程成功率监控
|
|
207
213
|
logger.logInfo({
|
|
208
|
-
title: '
|
|
214
|
+
title: 'create_antom_instance'
|
|
209
215
|
}, {
|
|
210
|
-
constructorName: constructorName
|
|
216
|
+
constructorName: constructorName,
|
|
217
|
+
result: 'Y'
|
|
211
218
|
});
|
|
212
219
|
consoleLogger.log('create_actual_instance_success');
|
|
213
220
|
_this2.actualInstance = actualInstance;
|
|
214
221
|
_this2.hasActualInstance = true;
|
|
215
222
|
_this2.executePendingCalls();
|
|
216
223
|
} catch (error) {
|
|
224
|
+
logger.logInfo({
|
|
225
|
+
title: 'create_antom_instance'
|
|
226
|
+
}, {
|
|
227
|
+
constructorName: constructorName,
|
|
228
|
+
result: 'N'
|
|
229
|
+
});
|
|
217
230
|
_this2.onCreateInstanceError(newProps);
|
|
218
231
|
}
|
|
219
232
|
}).catch(function () {
|
|
233
|
+
logger.logInfo({
|
|
234
|
+
title: 'create_antom_instance'
|
|
235
|
+
}, {
|
|
236
|
+
constructorName: constructorName,
|
|
237
|
+
result: 'N'
|
|
238
|
+
});
|
|
220
239
|
_this2.onLoadSDKError(newProps);
|
|
221
240
|
});
|
|
222
241
|
}
|
package/esm/loader/constant.js
CHANGED
|
@@ -31,6 +31,6 @@ export var instanceApiMap = _defineProperty(_defineProperty(_defineProperty({},
|
|
|
31
31
|
* SDK 地址
|
|
32
32
|
*/
|
|
33
33
|
export var SDK_URL = {
|
|
34
|
-
DEV: 'http://js-dev.antom.com/v2/ams-checkout.
|
|
35
|
-
PROD: 'https://js.antom.com/v2/ams-checkout.
|
|
34
|
+
DEV: 'http://js-dev.antom.com/v2/ams-checkout.js',
|
|
35
|
+
PROD: 'https://js.antom.com/v2/ams-checkout.js'
|
|
36
36
|
};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { EConstructorName, ProductType } from '../constant';
|
|
2
|
-
|
|
2
|
+
type SdkLoadResult = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
loadType?: 'cached' | 'network';
|
|
5
|
+
};
|
|
6
|
+
export declare function loadSdk(): Promise<SdkLoadResult>;
|
|
3
7
|
export declare function newActualInstance<T extends ProductType>(constructorName: EConstructorName, newProps: any): T | null;
|
|
8
|
+
export {};
|
|
@@ -17,14 +17,14 @@ export function loadSdk() {
|
|
|
17
17
|
new URL(sdkSrc);
|
|
18
18
|
} catch (e) {
|
|
19
19
|
consoleLogger.error("Invalid SDK URL: ".concat(sdkSrc));
|
|
20
|
-
reject(
|
|
20
|
+
reject();
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// 检查 SDK URL 是否存在
|
|
25
25
|
if (!sdkSrc) {
|
|
26
26
|
consoleLogger.error("SDK URL not found for: ".concat(sdkSrc));
|
|
27
|
-
reject(
|
|
27
|
+
reject();
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -32,7 +32,10 @@ export function loadSdk() {
|
|
|
32
32
|
var existingScript = document.querySelector("script[src=\"".concat(sdkSrc, "\"]"));
|
|
33
33
|
if (existingScript) {
|
|
34
34
|
consoleLogger.log("SDK already loaded: ".concat(sdkSrc));
|
|
35
|
-
resolve(
|
|
35
|
+
resolve({
|
|
36
|
+
success: true,
|
|
37
|
+
loadType: 'cached'
|
|
38
|
+
});
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -44,7 +47,10 @@ export function loadSdk() {
|
|
|
44
47
|
// 定义onload和onerror事件
|
|
45
48
|
script.onload = function () {
|
|
46
49
|
consoleLogger.log("Load SDK Success , SDK URL: ".concat(sdkSrc));
|
|
47
|
-
resolve(
|
|
50
|
+
resolve({
|
|
51
|
+
success: true,
|
|
52
|
+
loadType: 'network'
|
|
53
|
+
});
|
|
48
54
|
};
|
|
49
55
|
script.onerror = function () {
|
|
50
56
|
consoleLogger.log("Failed to load SDK: ".concat(sdkSrc));
|
|
@@ -55,7 +61,7 @@ export function loadSdk() {
|
|
|
55
61
|
});
|
|
56
62
|
// 失败时移除缓存脚本
|
|
57
63
|
script.remove();
|
|
58
|
-
reject(
|
|
64
|
+
reject();
|
|
59
65
|
};
|
|
60
66
|
});
|
|
61
67
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 在window对象上记录商户初始化SDK的StartTime,
|
|
3
|
+
* 后续在renderComponent时传递给Web应用,用于进行端到端渲染总耗时计算
|
|
4
|
+
* ***/
|
|
5
|
+
import { EConstructorName } from '../constant';
|
|
6
|
+
/*** 扩展 Window 接口,添加 _ANTOM_SDK_PROXY_START_TIME 属性*/
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
_ANTOM_SDK_PROXY_START_TIME?: Partial<Record<EConstructorName, number>>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare function setStartTime(constructorName: EConstructorName, startTime: number): number;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
/**
|
|
3
|
+
* 在window对象上记录商户初始化SDK的StartTime,
|
|
4
|
+
* 后续在renderComponent时传递给Web应用,用于进行端到端渲染总耗时计算
|
|
5
|
+
* ***/
|
|
6
|
+
|
|
7
|
+
/*** 扩展 Window 接口,添加 _ANTOM_SDK_PROXY_START_TIME 属性*/
|
|
8
|
+
|
|
9
|
+
/*** 往window对象上注入全局变量 _ANTOM_SDK_PROXY_START_TIME */
|
|
10
|
+
function injectAntomSDKProxyStartTime() {
|
|
11
|
+
if (typeof window === 'undefined') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (_typeof(window._ANTOM_SDK_PROXY_START_TIME) !== 'object') {
|
|
15
|
+
window._ANTOM_SDK_PROXY_START_TIME = {};
|
|
16
|
+
}
|
|
17
|
+
return window._ANTOM_SDK_PROXY_START_TIME;
|
|
18
|
+
}
|
|
19
|
+
export function setStartTime(constructorName, startTime) {
|
|
20
|
+
injectAntomSDKProxyStartTime();
|
|
21
|
+
if (_typeof(window._ANTOM_SDK_PROXY_START_TIME) === 'object') {
|
|
22
|
+
window._ANTOM_SDK_PROXY_START_TIME[constructorName] = startTime;
|
|
23
|
+
}
|
|
24
|
+
return startTime;
|
|
25
|
+
}
|
|
@@ -18,13 +18,11 @@ export function injectAntomSDKIntegrationType(integrationType) {
|
|
|
18
18
|
// 参数验证
|
|
19
19
|
var validTypes = ['CDN', 'NPM'];
|
|
20
20
|
if (!validTypes.includes(integrationType)) {
|
|
21
|
-
console.warn("Integration type must be one of: ".concat(validTypes.join(', ')));
|
|
22
21
|
return;
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
// 检查是否在浏览器环境中
|
|
26
25
|
if (typeof window === 'undefined') {
|
|
27
|
-
console.warn('window object is not available');
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
30
28
|
|
|
@@ -39,7 +37,6 @@ export function injectAntomSDKIntegrationType(integrationType) {
|
|
|
39
37
|
logger.setMedta({
|
|
40
38
|
integrationType: integrationType
|
|
41
39
|
});
|
|
42
|
-
console.log("Successfully injected window._ANTOM_SDK_INTEGRATION_TYPE: ".concat(integrationType));
|
|
43
40
|
}
|
|
44
41
|
|
|
45
42
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alipay/ams-checkout",
|
|
3
|
-
"version": "0.0.1762138227-dev.
|
|
3
|
+
"version": "0.0.1762138227-dev.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"main": "esm/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist",
|
|
11
11
|
"esm",
|
|
12
|
-
"ams-checkout.
|
|
12
|
+
"ams-checkout.js",
|
|
13
13
|
"LEGAL.md",
|
|
14
14
|
"LICENSE",
|
|
15
15
|
"README.md"
|