@alipay/ams-checkout 0.0.1708315090-dev.2 → 0.0.1708315090-dev.5
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.
@@ -17,7 +17,7 @@ export declare class AMSComponent extends CoreInstance {
|
|
17
17
|
*/
|
18
18
|
createComponent(params: IcreateComponent): Promise<void>;
|
19
19
|
preloadComponent(channelType: any, productSceneVersion: any): void;
|
20
|
-
clearPreloadIframe(): void;
|
20
|
+
clearPreloadIframe(isTimeOut?: boolean): void;
|
21
21
|
/**
|
22
22
|
* @description Create and render components in the specified element area
|
23
23
|
* @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
|
@@ -161,12 +161,31 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
161
161
|
_ref2$paymentSessionM4 = _ref2$paymentSessionM.productSceneVersion,
|
162
162
|
productSceneVersion = _ref2$paymentSessionM4 === void 0 ? '' : _ref2$paymentSessionM4;
|
163
163
|
var channelType = "".concat(productScene, "_").concat(paymentMethodCategoryType);
|
164
|
-
if (productScene && productSceneVersion) {
|
164
|
+
if (productScene && paymentMethodCategoryType && productSceneVersion) {
|
165
|
+
if (this.channelType.includes(channelType) && this.productSceneVersion === productSceneVersion) {
|
166
|
+
this.logger.logInfo({
|
167
|
+
title: 'preload_match'
|
168
|
+
}, {
|
169
|
+
preloadChannel: this.channelType,
|
170
|
+
preloadVersion: this.productSceneVersion,
|
171
|
+
sessionDataChannel: channelType,
|
172
|
+
sessionDataVersion: productSceneVersion
|
173
|
+
});
|
174
|
+
} else {
|
175
|
+
this.logger.logInfo({
|
176
|
+
title: 'preload_no_match'
|
177
|
+
}, {
|
178
|
+
preloadChannel: this.channelType,
|
179
|
+
preloadVersion: this.productSceneVersion,
|
180
|
+
sessionDataChannel: channelType,
|
181
|
+
sessionDataVersion: productSceneVersion
|
182
|
+
});
|
183
|
+
}
|
165
184
|
var previousChannel = {
|
166
185
|
channelType: channelType === componentSignEnum.VAULTING_CARD ? componentSignEnum.CASHIER_PAYMENT_CARD : channelType,
|
167
186
|
productSceneVersion: productSceneVersion
|
168
187
|
};
|
169
|
-
localStorage.setItem('
|
188
|
+
localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
|
170
189
|
}
|
171
190
|
}
|
172
191
|
/**
|
@@ -203,25 +222,41 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
203
222
|
var _this3 = this;
|
204
223
|
this.channelType = channelType;
|
205
224
|
this.productSceneVersion = productSceneVersion;
|
206
|
-
var MAX_CLEAR_TIME =
|
225
|
+
var MAX_CLEAR_TIME = 90000;
|
207
226
|
if (Array.isArray(channelType)) {
|
208
227
|
for (var i = 0; i < channelType.length; i++) {
|
209
228
|
this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
|
210
229
|
}
|
230
|
+
} else {
|
231
|
+
this.logger.logError({
|
232
|
+
title: 'performance_optimization_channelType_error'
|
233
|
+
}, {
|
234
|
+
channelType: channelType
|
235
|
+
});
|
211
236
|
}
|
212
237
|
setTimeout(function () {
|
213
|
-
_this3.clearPreloadIframe();
|
238
|
+
_this3.clearPreloadIframe(true);
|
214
239
|
}, MAX_CLEAR_TIME);
|
215
240
|
}
|
216
241
|
}, {
|
217
242
|
key: "clearPreloadIframe",
|
218
243
|
value: function clearPreloadIframe() {
|
244
|
+
var isTimeOut = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
219
245
|
if (Array.isArray(this.channelType)) {
|
220
246
|
for (var i = 0; i < this.channelType.length; i++) {
|
221
247
|
var iframe = document.getElementById("ams-checkout-component-".concat(this.channelType[i], "-").concat(this.productSceneVersion));
|
222
248
|
iframe && document.body.removeChild(iframe);
|
223
249
|
}
|
224
250
|
}
|
251
|
+
if (!isTimeOut) {
|
252
|
+
this.logger.logInfo({
|
253
|
+
title: 'performance_optimization_clearPreloadIframe'
|
254
|
+
});
|
255
|
+
} else {
|
256
|
+
this.logger.logInfo({
|
257
|
+
title: 'performance_optimization_clearPreloadIframe_timeout'
|
258
|
+
});
|
259
|
+
}
|
225
260
|
}
|
226
261
|
/**
|
227
262
|
* @description Create and render components in the specified element area
|
@@ -232,6 +267,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
232
267
|
key: "mountComponent",
|
233
268
|
value: function mountComponent(params, selector) {
|
234
269
|
var _this4 = this;
|
270
|
+
this.clearPreloadIframe();
|
235
271
|
return this.parameterInitAndCheck({
|
236
272
|
params: params,
|
237
273
|
renderDisplayType: renderDisplayTypeEnum.inline,
|
package/esm/index.js
CHANGED
@@ -22,6 +22,8 @@ import ApplePayComponent from "./core/applepay";
|
|
22
22
|
import { AMSComponent } from "./core/component/index";
|
23
23
|
import { componentSignEnum } from "./types";
|
24
24
|
import { productSceneEnum } from "./types/index";
|
25
|
+
import { Logger, LogConfig } from "./util/logger";
|
26
|
+
var logger = new Logger(LogConfig, true);
|
25
27
|
export * from "./types";
|
26
28
|
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
27
29
|
_inherits(AMSCheckout, _AMSComponent);
|
@@ -67,7 +69,7 @@ export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
|
|
67
69
|
});
|
68
70
|
var currentProductSceneVersion = '1.0';
|
69
71
|
try {
|
70
|
-
var previousChannelStr = localStorage.getItem('
|
72
|
+
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
71
73
|
var previousChannel = JSON.parse(previousChannelStr) || {};
|
72
74
|
var _ref = previousChannel || {},
|
73
75
|
_ref$channelType = _ref.channelType,
|
@@ -78,7 +80,11 @@ export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout2) {
|
|
78
80
|
currentProductSceneVersion = productSceneVersion;
|
79
81
|
}
|
80
82
|
} catch (error) {
|
81
|
-
|
83
|
+
logger.logError({
|
84
|
+
title: 'performance_optimization_get_previousChannel_error'
|
85
|
+
}, {
|
86
|
+
error: error
|
87
|
+
});
|
82
88
|
}
|
83
89
|
return _super4.call(this, _options, [componentSignEnum.EASY_PAY_WALLET], currentProductSceneVersion);
|
84
90
|
}
|
@@ -94,7 +100,7 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
94
100
|
});
|
95
101
|
var currentChannelType;
|
96
102
|
try {
|
97
|
-
var previousChannelStr = localStorage.getItem('
|
103
|
+
var previousChannelStr = localStorage.getItem('antom_checkout_previousChannel');
|
98
104
|
var previousChannel = JSON.parse(previousChannelStr) || {};
|
99
105
|
var _ref2 = previousChannel || {},
|
100
106
|
_ref2$channelType = _ref2.channelType,
|
@@ -105,7 +111,11 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
|
|
105
111
|
currentChannelType = [componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.CASHIER_PAYMENT_APM];
|
106
112
|
}
|
107
113
|
} catch (error) {
|
108
|
-
|
114
|
+
logger.logError({
|
115
|
+
title: 'performance_optimization_get_previousChannel_error'
|
116
|
+
}, {
|
117
|
+
error: error
|
118
|
+
});
|
109
119
|
}
|
110
120
|
return _super5.call(this, _options, currentChannelType);
|
111
121
|
}
|
@@ -294,6 +294,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
294
294
|
value: function appendPreloadIframeNodes(componentSign, productSceneVersion) {
|
295
295
|
var virtualPreloadIframe = this.createPreloadApp(componentSign, productSceneVersion);
|
296
296
|
this.createPreloadIframeNode(virtualPreloadIframe);
|
297
|
+
this.AMSSDK.logger.logInfo({
|
298
|
+
title: 'performance_optimization_preload'
|
299
|
+
}, {
|
300
|
+
componentSign: componentSign,
|
301
|
+
productSceneVersion: productSceneVersion
|
302
|
+
});
|
297
303
|
}
|
298
304
|
}, {
|
299
305
|
key: "setParameterDefaultValues",
|
@@ -357,8 +363,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
357
363
|
// eslint-disable-next-line no-async-promise-executor
|
358
364
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
359
365
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
360
|
-
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5
|
361
|
-
var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, extendInfoData, _this5$
|
366
|
+
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
|
367
|
+
var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, extendInfoData, _this5$_renderParams6, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams7, _action$web, _action$wap, action, signType;
|
362
368
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
363
369
|
while (1) switch (_context2.prev = _context2.next) {
|
364
370
|
case 0:
|
@@ -391,81 +397,78 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
391
397
|
success: true
|
392
398
|
}));
|
393
399
|
case 7:
|
394
|
-
|
395
|
-
|
396
|
-
_this5$_renderParams$2 = (_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.paymentSessionMetaData, _this5$_renderParams$3 = _this5$_renderParams$2.paymentSessionFactor, paymentSessionFactor = _this5$_renderParams$3 === void 0 ? null : _this5$_renderParams$3;
|
397
|
-
if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign && (_this5$_renderParams6 = _this5._renderParams) !== null && _this5$_renderParams6 !== void 0 && (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) !== null && _this5$_renderParams6 !== void 0 && (_this5$_renderParams6 = _this5$_renderParams6.action) !== null && _this5$_renderParams6 !== void 0 && _this5$_renderParams6.skipSdkQuery && enableVaultingApiOptimize && paymentSessionFactor)) {
|
398
|
-
_context2.next = 10;
|
400
|
+
if (!(componentSignEnum.VAULTING_CARD === _this5._componentSign && (_this5$_renderParams5 = _this5._renderParams) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) !== null && _this5$_renderParams5 !== void 0 && (_this5$_renderParams5 = _this5$_renderParams5.action) !== null && _this5$_renderParams5 !== void 0 && _this5$_renderParams5.skipSdkQuery && enableVaultingApiOptimize)) {
|
401
|
+
_context2.next = 9;
|
399
402
|
break;
|
400
403
|
}
|
401
404
|
return _context2.abrupt("return", resolve({
|
402
405
|
message: 'sdk no need to make query request',
|
403
406
|
success: true
|
404
407
|
}));
|
405
|
-
case
|
408
|
+
case 9:
|
406
409
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
407
|
-
_context2.next =
|
410
|
+
_context2.next = 15;
|
408
411
|
break;
|
409
412
|
}
|
410
413
|
params.paymentMethodType = 'CARD';
|
411
|
-
_context2.next =
|
414
|
+
_context2.next = 13;
|
412
415
|
return _this5.getDeviceIdAndLog();
|
413
|
-
case
|
416
|
+
case 13:
|
414
417
|
envInfo.deviceId = _context2.sent;
|
415
418
|
if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
|
416
419
|
envInfo.extendInfo = {
|
417
420
|
WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
|
418
421
|
};
|
419
422
|
}
|
420
|
-
case
|
423
|
+
case 15:
|
421
424
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
422
|
-
_context2.next =
|
425
|
+
_context2.next = 23;
|
423
426
|
break;
|
424
427
|
}
|
425
428
|
_ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
|
426
|
-
_ref4 = ((_this5$
|
429
|
+
_ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
427
430
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
428
|
-
_context2.next =
|
431
|
+
_context2.next = 20;
|
429
432
|
break;
|
430
433
|
}
|
431
434
|
return _context2.abrupt("return", resolve({
|
432
435
|
message: 'sdk no need to make query request',
|
433
436
|
success: true
|
434
437
|
}));
|
435
|
-
case
|
436
|
-
_context2.next =
|
438
|
+
case 20:
|
439
|
+
_context2.next = 22;
|
437
440
|
return _this5.getDeviceIdAndLog();
|
438
|
-
case
|
441
|
+
case 22:
|
439
442
|
envInfo.deviceId = _context2.sent;
|
440
|
-
case
|
443
|
+
case 23:
|
441
444
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
442
|
-
_context2.next =
|
445
|
+
_context2.next = 33;
|
443
446
|
break;
|
444
447
|
}
|
445
|
-
action = ((_this5$
|
448
|
+
action = ((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 || (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.action) || {};
|
446
449
|
signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
|
447
450
|
if (!(signType === 'SMS')) {
|
448
|
-
_context2.next =
|
451
|
+
_context2.next = 28;
|
449
452
|
break;
|
450
453
|
}
|
451
454
|
return _context2.abrupt("return", resolve({
|
452
455
|
message: 'sdk no need to make query request',
|
453
456
|
success: true
|
454
457
|
}));
|
455
|
-
case
|
458
|
+
case 28:
|
456
459
|
if (!(!signType || signType !== 'REDIRECT')) {
|
457
|
-
_context2.next =
|
460
|
+
_context2.next = 30;
|
458
461
|
break;
|
459
462
|
}
|
460
463
|
return _context2.abrupt("return", resolve({
|
461
464
|
success: false
|
462
465
|
}));
|
463
|
-
case
|
464
|
-
_context2.next =
|
466
|
+
case 30:
|
467
|
+
_context2.next = 32;
|
465
468
|
return _this5.getDeviceIdAndLog();
|
466
|
-
case
|
469
|
+
case 32:
|
467
470
|
envInfo.deviceId = _context2.sent;
|
468
|
-
case
|
471
|
+
case 33:
|
469
472
|
_this5.AMSSDK.logger.logInfo({
|
470
473
|
title: 'sdk_event_sdkQuery'
|
471
474
|
}, {
|
@@ -497,7 +500,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
497
500
|
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
498
501
|
}).send();
|
499
502
|
});
|
500
|
-
case
|
503
|
+
case 35:
|
501
504
|
case "end":
|
502
505
|
return _context2.stop();
|
503
506
|
}
|
@@ -650,7 +653,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
650
653
|
path = _getIframeUrl.path,
|
651
654
|
locationSearch = _getIframeUrl.locationSearch;
|
652
655
|
preloadIframe.src = "".concat(path, "?").concat(locationSearch);
|
653
|
-
|
656
|
+
if (!path) {
|
657
|
+
this.AMSSDK.logger.logError({
|
658
|
+
title: 'performance_optimization_preload_path_error'
|
659
|
+
}, {
|
660
|
+
path: path,
|
661
|
+
locationSearch: locationSearch
|
662
|
+
});
|
663
|
+
}
|
654
664
|
return preloadIframe;
|
655
665
|
}
|
656
666
|
/**
|