@alipay/ams-checkout 1.6.2 → 1.7.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/constant/index.d.ts +17 -7
- package/esm/constant/index.js +18 -8
- package/esm/core/component/index.js +12 -2
- package/esm/core/instance/index.js +3 -3
- package/esm/index.js +2 -2
- package/esm/plugin/component/cashierApp.js +3 -4
- package/esm/plugin/component/index.d.ts +8 -5
- package/esm/plugin/component/index.js +251 -95
- package/esm/plugin/component/popupWindow.style.d.ts +4 -2
- package/esm/plugin/component/popupWindow.style.js +35 -24
- package/esm/plugin/drop-in/index.js +2 -2
- package/esm/request/index.js +5 -5
- package/esm/service/index.js +2 -2
- package/esm/types/index.d.ts +0 -7
- package/esm/util/index.js +2 -2
- package/esm/util/logger.d.ts +1 -0
- package/esm/util/logger.js +5 -2
- package/esm/util/security.js +4 -5
- package/package.json +1 -1
@@ -6,8 +6,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
6
6
|
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); } }
|
7
7
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
8
8
|
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; }
|
9
|
-
function _toPropertyKey(
|
10
|
-
function _toPrimitive(
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
10
|
+
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); }
|
11
11
|
/**
|
12
12
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
13
13
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
@@ -15,8 +15,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
15
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
16
16
|
*/
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
|
-
import {
|
19
|
-
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
18
|
+
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT } from "../../constant";
|
20
19
|
import { queryPaymentInfo, submitPayInfo } from "../../service";
|
21
20
|
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
22
21
|
import { getType, isJsonString, isPC } from "../../util";
|
@@ -35,8 +34,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
35
34
|
_defineProperty(this, "_performanceData", []);
|
36
35
|
_defineProperty(this, "_loadAppPromiseResolve", null);
|
37
36
|
_defineProperty(this, "_isInitComponent", void 0);
|
38
|
-
_defineProperty(this, "
|
39
|
-
_defineProperty(this, "
|
37
|
+
_defineProperty(this, "_globalData", void 0);
|
38
|
+
_defineProperty(this, "popupApp", void 0);
|
40
39
|
_defineProperty(this, "appDomain", void 0);
|
41
40
|
_defineProperty(this, "createIframeNode", void 0);
|
42
41
|
_defineProperty(this, "_selector", void 0);
|
@@ -49,7 +48,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
49
48
|
_defineProperty(this, "_appLocationSearch", void 0);
|
50
49
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
51
50
|
_defineProperty(this, "_multipleCallbackEvents", void 0);
|
52
|
-
this._appVersion = '1.
|
51
|
+
this._appVersion = '1.7.1';
|
53
52
|
this._isInitComponent = false;
|
54
53
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
55
54
|
this.createIframeNode = function () {
|
@@ -62,6 +61,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
62
61
|
key: 'sdk_init',
|
63
62
|
value: Date.now()
|
64
63
|
});
|
64
|
+
this._globalData = new Map();
|
65
65
|
}
|
66
66
|
|
67
67
|
/**
|
@@ -85,7 +85,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
85
85
|
}, {
|
86
86
|
key: "initLoggerMeta",
|
87
87
|
value: function initLoggerMeta() {
|
88
|
-
var _this$_renderParams, _paymentSessionMetaDa;
|
88
|
+
var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2;
|
89
89
|
var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
|
90
90
|
var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
|
91
91
|
this.AMSSDK.logger.setMedta({
|
@@ -100,7 +100,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
100
100
|
productScene: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productScene,
|
101
101
|
productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
|
102
102
|
paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
|
103
|
-
paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType
|
103
|
+
paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
|
104
|
+
requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData
|
104
105
|
});
|
105
106
|
this.AMSSDK.logger.setComponentStartTime(Date.now());
|
106
107
|
}
|
@@ -116,9 +117,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
116
117
|
}, {
|
117
118
|
key: "initSecurity",
|
118
119
|
value: function initSecurity() {
|
119
|
-
var _this$
|
120
|
+
var _this$_renderParams3,
|
120
121
|
_this = this;
|
121
|
-
var product = (_this$
|
122
|
+
var product = (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionMetaData) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionConfig) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.productScene;
|
122
123
|
if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
|
123
124
|
this.AMSSDK.logger.logInfo({
|
124
125
|
title: 'sdk_event_security_unneeded_scenarios'
|
@@ -227,19 +228,24 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
227
228
|
}, {
|
228
229
|
key: "appendIframeNodes",
|
229
230
|
value: function appendIframeNodes(componentSign, renderParams) {
|
230
|
-
var
|
231
|
+
var _renderParams,
|
232
|
+
_this3 = this;
|
231
233
|
if (this._isInitComponent) {
|
232
234
|
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
233
235
|
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
|
234
236
|
}
|
237
|
+
renderParams = this.setParameterDefaultValues(componentSign, renderParams);
|
235
238
|
this._isInitComponent = true;
|
236
239
|
this._renderParams = renderParams;
|
237
240
|
this._componentSign = componentSign;
|
238
|
-
if (renderParams !== null &&
|
241
|
+
if ((_renderParams = renderParams) !== null && _renderParams !== void 0 && _renderParams.selector) this._selector = renderParams.selector;
|
239
242
|
this._renderDisplayType = renderParams.renderDisplayType;
|
240
243
|
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
241
|
-
this.initSecurity();
|
242
244
|
this.initLoggerMeta();
|
245
|
+
this.AMSSDK.logger.logInfo({
|
246
|
+
title: 'sdk_event_createComponent'
|
247
|
+
}).send();
|
248
|
+
this.initSecurity();
|
243
249
|
this._performanceData.push({
|
244
250
|
key: 'sdk_create_component',
|
245
251
|
value: Date.now()
|
@@ -270,6 +276,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
270
276
|
return Promise.reject(error);
|
271
277
|
});
|
272
278
|
}
|
279
|
+
}, {
|
280
|
+
key: "setParameterDefaultValues",
|
281
|
+
value: function setParameterDefaultValues(componentSign, renderParams) {
|
282
|
+
var newParams = Object.assign({}, renderParams);
|
283
|
+
if (componentSign === componentSignEnum.VAULTING_CARD) {
|
284
|
+
var _newParams$notRedirec;
|
285
|
+
newParams.notRedirectAfterComplete = (_newParams$notRedirec = newParams === null || newParams === void 0 ? void 0 : newParams.notRedirectAfterComplete) !== null && _newParams$notRedirec !== void 0 ? _newParams$notRedirec : true;
|
286
|
+
}
|
287
|
+
return newParams;
|
288
|
+
}
|
273
289
|
}, {
|
274
290
|
key: "renderInlineLoading",
|
275
291
|
value: function renderInlineLoading(renderParams, selector) {
|
@@ -291,18 +307,15 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
291
307
|
}
|
292
308
|
}, {
|
293
309
|
key: "_createLoadAppPromise",
|
294
|
-
value: function _createLoadAppPromise() {
|
310
|
+
value: function _createLoadAppPromise(loadTimeLimit) {
|
295
311
|
var _this4 = this;
|
296
312
|
return new Promise(function (resolve, reject) {
|
297
313
|
_this4._loadAppPromiseResolve = resolve;
|
298
314
|
setTimeout(function () {
|
299
315
|
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
300
|
-
}, LOADTIME_LIMIT);
|
316
|
+
}, loadTimeLimit !== null && loadTimeLimit !== void 0 ? loadTimeLimit : LOADTIME_LIMIT);
|
301
317
|
}).catch(function (error) {
|
302
|
-
_this4.dispatchToSDK(EVENT.error.name,
|
303
|
-
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
304
|
-
message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
|
305
|
-
});
|
318
|
+
_this4.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
306
319
|
_this4.AMSSDK.logger.logError({
|
307
320
|
title: 'sdk_error_web_app_timeout'
|
308
321
|
}).send();
|
@@ -326,7 +339,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
326
339
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
327
340
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
328
341
|
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4;
|
329
|
-
var envInfo, params, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
|
342
|
+
var envInfo, params, search, _this5$_renderParams5, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams6, _action$web, _action$wap, action, signType;
|
330
343
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
331
344
|
while (1) switch (_context2.prev = _context2.next) {
|
332
345
|
case 0:
|
@@ -351,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
351
364
|
}));
|
352
365
|
case 4:
|
353
366
|
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
354
|
-
_context2.next =
|
367
|
+
_context2.next = 11;
|
355
368
|
break;
|
356
369
|
}
|
357
370
|
params.paymentMethodType = 'CARD';
|
@@ -359,55 +372,62 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
359
372
|
return _this5.getDeviceIdAndLog();
|
360
373
|
case 8:
|
361
374
|
envInfo.deviceId = _context2.sent;
|
362
|
-
|
375
|
+
// TODO 加一个后门 判断是否为小程序环境
|
376
|
+
search = window.location.search;
|
377
|
+
if (window.navigator.userAgent.indexOf('miniProgram') > -1 || search.indexOf('miniProgram') > -1) {
|
378
|
+
envInfo.extendInfo = {
|
379
|
+
WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
|
380
|
+
};
|
381
|
+
}
|
382
|
+
case 11:
|
363
383
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
364
|
-
_context2.next =
|
384
|
+
_context2.next = 19;
|
365
385
|
break;
|
366
386
|
}
|
367
387
|
_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;
|
368
388
|
_ref4 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.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;
|
369
389
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
370
|
-
_context2.next =
|
390
|
+
_context2.next = 16;
|
371
391
|
break;
|
372
392
|
}
|
373
393
|
return _context2.abrupt("return", resolve({
|
374
394
|
message: 'sdk no need to make query request',
|
375
395
|
success: true
|
376
396
|
}));
|
377
|
-
case 14:
|
378
|
-
_context2.next = 16;
|
379
|
-
return _this5.getDeviceIdAndLog();
|
380
397
|
case 16:
|
398
|
+
_context2.next = 18;
|
399
|
+
return _this5.getDeviceIdAndLog();
|
400
|
+
case 18:
|
381
401
|
envInfo.deviceId = _context2.sent;
|
382
|
-
case
|
402
|
+
case 19:
|
383
403
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
384
|
-
_context2.next =
|
404
|
+
_context2.next = 29;
|
385
405
|
break;
|
386
406
|
}
|
387
407
|
action = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 || (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.action) || {};
|
388
408
|
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;
|
389
409
|
if (!(signType === 'SMS')) {
|
390
|
-
_context2.next =
|
410
|
+
_context2.next = 24;
|
391
411
|
break;
|
392
412
|
}
|
393
413
|
return _context2.abrupt("return", resolve({
|
394
414
|
message: 'sdk no need to make query request',
|
395
415
|
success: true
|
396
416
|
}));
|
397
|
-
case
|
417
|
+
case 24:
|
398
418
|
if (!(!signType || signType !== 'REDIRECT')) {
|
399
|
-
_context2.next =
|
419
|
+
_context2.next = 26;
|
400
420
|
break;
|
401
421
|
}
|
402
422
|
return _context2.abrupt("return", resolve({
|
403
423
|
success: false
|
404
424
|
}));
|
405
|
-
case 24:
|
406
|
-
_context2.next = 26;
|
407
|
-
return _this5.getDeviceIdAndLog();
|
408
425
|
case 26:
|
426
|
+
_context2.next = 28;
|
427
|
+
return _this5.getDeviceIdAndLog();
|
428
|
+
case 28:
|
409
429
|
envInfo.deviceId = _context2.sent;
|
410
|
-
case
|
430
|
+
case 29:
|
411
431
|
_this5.AMSSDK.logger.logInfo({
|
412
432
|
title: 'sdk_event_sdkQuery'
|
413
433
|
}, {
|
@@ -427,7 +447,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
427
447
|
resolve(res);
|
428
448
|
}
|
429
449
|
}).catch(function (err) {
|
430
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD
|
450
|
+
if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD].includes(_this5._componentSign)) {
|
431
451
|
return resolve({
|
432
452
|
success: false
|
433
453
|
});
|
@@ -443,7 +463,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
443
463
|
paymentSessionConfig: JSON.stringify(params.paymentSessionConfig)
|
444
464
|
}).send();
|
445
465
|
});
|
446
|
-
case
|
466
|
+
case 31:
|
447
467
|
case "end":
|
448
468
|
return _context2.stop();
|
449
469
|
}
|
@@ -458,16 +478,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
458
478
|
}, {
|
459
479
|
key: "createSubmitPromise",
|
460
480
|
value: function createSubmitPromise() {
|
461
|
-
var _this$
|
462
|
-
_this$
|
481
|
+
var _this$_renderParams4,
|
482
|
+
_this$_renderParams5,
|
463
483
|
_this6 = this;
|
464
484
|
this._performanceData.push({
|
465
485
|
key: 'sdk_submit_start',
|
466
486
|
value: Date.now()
|
467
487
|
});
|
468
488
|
var params = {
|
469
|
-
paymentSessionData: this._renderParams && ((_this$
|
470
|
-
paymentSessionConfig: (_this$
|
489
|
+
paymentSessionData: this._renderParams && ((_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData) || '',
|
490
|
+
paymentSessionConfig: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 || (_this$_renderParams5 = _this$_renderParams5.paymentSessionMetaData) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.paymentSessionConfig
|
471
491
|
};
|
472
492
|
|
473
493
|
// eslint-disable-next-line no-async-promise-executor
|
@@ -617,6 +637,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
617
637
|
// Subscribe to messages from iframe
|
618
638
|
this.addEventListener();
|
619
639
|
} catch (error) {
|
640
|
+
this.AMSSDK.logger.logError({
|
641
|
+
title: 'sdk_error_created_app_failed'
|
642
|
+
}).send();
|
620
643
|
this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
|
621
644
|
stack: error
|
622
645
|
}));
|
@@ -653,33 +676,81 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
653
676
|
});
|
654
677
|
}
|
655
678
|
}, {
|
656
|
-
key: "
|
657
|
-
value: function
|
658
|
-
var
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
679
|
+
key: "createDialog",
|
680
|
+
value: function () {
|
681
|
+
var _createDialog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
|
682
|
+
var pageUrl, isLoad, timeout, logTimeout;
|
683
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
684
|
+
while (1) switch (_context4.prev = _context4.next) {
|
685
|
+
case 0:
|
686
|
+
pageUrl = data.url.includes('?') ? "".concat(data.url, "&").concat(this._appLocationSearch) : "".concat(data.url, "?").concat(this._appLocationSearch);
|
687
|
+
_context4.prev = 1;
|
688
|
+
isLoad = false;
|
689
|
+
_context4.next = 5;
|
690
|
+
return createModal({
|
691
|
+
widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
|
692
|
+
heightPadding: data === null || data === void 0 ? void 0 : data.heightPadding,
|
693
|
+
device: this.platform,
|
694
|
+
url: pageUrl
|
695
|
+
});
|
696
|
+
case 5:
|
697
|
+
this.popupApp = _context4.sent;
|
698
|
+
timeout = setTimeout(function () {
|
699
|
+
if (isLoad) return;
|
700
|
+
throw {
|
701
|
+
title: 'sdk_error_create_pop_up'
|
702
|
+
};
|
703
|
+
}, LOADTIME_LIMIT);
|
704
|
+
logTimeout = setTimeout(function () {
|
705
|
+
if (isLoad) return;
|
706
|
+
throw {
|
707
|
+
title: 'sdk_error_pop_up_time_out'
|
708
|
+
};
|
709
|
+
}, POPUP_LOADTIME_LOG_LIMIT);
|
710
|
+
this.popupApp.onload = function () {
|
711
|
+
isLoad = true;
|
712
|
+
clearTimeout(timeout);
|
713
|
+
clearTimeout(logTimeout);
|
714
|
+
};
|
715
|
+
_context4.next = 15;
|
716
|
+
break;
|
717
|
+
case 11:
|
718
|
+
_context4.prev = 11;
|
719
|
+
_context4.t0 = _context4["catch"](1);
|
720
|
+
this.AMSSDK.logger.logError({
|
721
|
+
title: (_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.title) || 'sdk_error_create_pop_up'
|
722
|
+
}, {
|
723
|
+
message: _context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message,
|
724
|
+
url: pageUrl
|
725
|
+
});
|
726
|
+
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
727
|
+
case 15:
|
728
|
+
case "end":
|
729
|
+
return _context4.stop();
|
730
|
+
}
|
731
|
+
}, _callee4, this, [[1, 11]]);
|
732
|
+
}));
|
733
|
+
function createDialog(_x4) {
|
734
|
+
return _createDialog.apply(this, arguments);
|
735
|
+
}
|
736
|
+
return createDialog;
|
737
|
+
}()
|
667
738
|
}, {
|
668
739
|
key: "getDeviceIdAndCallback",
|
669
740
|
value: function () {
|
670
|
-
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
741
|
+
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventContext) {
|
671
742
|
var deviceId;
|
672
|
-
return _regeneratorRuntime().wrap(function
|
673
|
-
while (1) switch (
|
743
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
744
|
+
while (1) switch (_context5.prev = _context5.next) {
|
674
745
|
case 0:
|
675
746
|
if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
|
676
|
-
|
747
|
+
_context5.next = 5;
|
677
748
|
break;
|
678
749
|
}
|
679
|
-
|
750
|
+
_context5.next = 3;
|
680
751
|
return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
|
681
752
|
case 3:
|
682
|
-
deviceId =
|
753
|
+
deviceId = _context5.sent;
|
683
754
|
this.dispatchToApp({
|
684
755
|
context: {
|
685
756
|
event: 'appEventCallback',
|
@@ -691,15 +762,78 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
691
762
|
});
|
692
763
|
case 5:
|
693
764
|
case "end":
|
694
|
-
return
|
765
|
+
return _context5.stop();
|
695
766
|
}
|
696
|
-
},
|
767
|
+
}, _callee5, this);
|
697
768
|
}));
|
698
|
-
function getDeviceIdAndCallback(
|
769
|
+
function getDeviceIdAndCallback(_x5) {
|
699
770
|
return _getDeviceIdAndCallback.apply(this, arguments);
|
700
771
|
}
|
701
772
|
return getDeviceIdAndCallback;
|
702
773
|
}()
|
774
|
+
}, {
|
775
|
+
key: "getUserAgentAndCallback",
|
776
|
+
value: function () {
|
777
|
+
var _getUserAgentAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(eventContext) {
|
778
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
779
|
+
while (1) switch (_context6.prev = _context6.next) {
|
780
|
+
case 0:
|
781
|
+
if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
|
782
|
+
try {
|
783
|
+
this.dispatchToApp({
|
784
|
+
context: {
|
785
|
+
event: 'appEventCallback',
|
786
|
+
eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
|
787
|
+
data: {
|
788
|
+
// TODO 预发前删除window.location.search,这个是用于调试配置的后门
|
789
|
+
userAgent: window.navigator.userAgent + window.location.search
|
790
|
+
}
|
791
|
+
}
|
792
|
+
});
|
793
|
+
} catch (error) {
|
794
|
+
/* empty */
|
795
|
+
}
|
796
|
+
}
|
797
|
+
case 1:
|
798
|
+
case "end":
|
799
|
+
return _context6.stop();
|
800
|
+
}
|
801
|
+
}, _callee6, this);
|
802
|
+
}));
|
803
|
+
function getUserAgentAndCallback(_x6) {
|
804
|
+
return _getUserAgentAndCallback.apply(this, arguments);
|
805
|
+
}
|
806
|
+
return getUserAgentAndCallback;
|
807
|
+
}()
|
808
|
+
}, {
|
809
|
+
key: "returnDataAndCallback",
|
810
|
+
value: function () {
|
811
|
+
var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventContext) {
|
812
|
+
var _eventContext$data, targetData;
|
813
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
814
|
+
while (1) switch (_context7.prev = _context7.next) {
|
815
|
+
case 0:
|
816
|
+
if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
|
817
|
+
targetData = this._globalData.get((_eventContext$data = eventContext.data) === null || _eventContext$data === void 0 ? void 0 : _eventContext$data.dataKey);
|
818
|
+
this.dispatchToApp({
|
819
|
+
context: {
|
820
|
+
event: 'appEventCallback',
|
821
|
+
eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
|
822
|
+
data: targetData
|
823
|
+
}
|
824
|
+
});
|
825
|
+
}
|
826
|
+
case 1:
|
827
|
+
case "end":
|
828
|
+
return _context7.stop();
|
829
|
+
}
|
830
|
+
}, _callee7, this);
|
831
|
+
}));
|
832
|
+
function returnDataAndCallback(_x7) {
|
833
|
+
return _returnDataAndCallback.apply(this, arguments);
|
834
|
+
}
|
835
|
+
return returnDataAndCallback;
|
836
|
+
}()
|
703
837
|
/**
|
704
838
|
* @description Initialize subscription iframe message
|
705
839
|
*/
|
@@ -725,7 +859,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
725
859
|
}, {
|
726
860
|
key: "_handleAppMessage",
|
727
861
|
value: function _handleAppMessage(data) {
|
728
|
-
var eventKeyMap =
|
862
|
+
var eventKeyMap = Object.keys(EVENT).map(function (key) {
|
863
|
+
return EVENT[key].name;
|
864
|
+
});
|
729
865
|
if (!eventKeyMap.includes(data.context.event)) {
|
730
866
|
return;
|
731
867
|
}
|
@@ -733,29 +869,42 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
733
869
|
this.getDeviceIdAndCallback(data.context);
|
734
870
|
return;
|
735
871
|
}
|
736
|
-
if (data.context.event === EVENT.
|
872
|
+
if (data.context.event === EVENT.getUserAgentFromSdk.name) {
|
873
|
+
this.getUserAgentAndCallback(data.context);
|
874
|
+
return;
|
875
|
+
}
|
876
|
+
if (data.context.event === EVENT.popWindow.name) {
|
737
877
|
destroyModal();
|
738
878
|
return;
|
739
879
|
}
|
740
|
-
if (data.context.event === EVENT.
|
741
|
-
this.
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
880
|
+
if (data.context.event === EVENT.getGlobalData.name) {
|
881
|
+
this.returnDataAndCallback(data.context);
|
882
|
+
return;
|
883
|
+
}
|
884
|
+
if (data.context.event === EVENT.setGlobalData.name) {
|
885
|
+
var _data$context$data, _data$context$data2;
|
886
|
+
this._globalData.set((_data$context$data = data.context.data) === null || _data$context$data === void 0 ? void 0 : _data$context$data.dataKey, (_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.data);
|
747
887
|
return;
|
748
888
|
}
|
749
889
|
if (data.context.event === EVENT.popupWindow.name) {
|
750
890
|
var _data$context;
|
751
|
-
this.
|
891
|
+
this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
|
892
|
+
return;
|
893
|
+
}
|
894
|
+
if (data.context.event === EVENT.sendMuitiAppEventToSdk.name) {
|
895
|
+
this.dispatchToApp({
|
896
|
+
context: {
|
897
|
+
event: 'receiveMuitiAppFromSdk',
|
898
|
+
data: data.context.data
|
899
|
+
}
|
900
|
+
});
|
752
901
|
return;
|
753
902
|
}
|
754
903
|
if (data.context.event === EVENT.dismissLoading.name) {
|
755
|
-
var _data$context$
|
904
|
+
var _data$context$data3;
|
756
905
|
this.dispatchToSDK(EVENT.eventCallback.name, {
|
757
906
|
code: 'SDK_END_OF_LOADING',
|
758
|
-
message: ((_data$context$
|
907
|
+
message: ((_data$context$data3 = data.context.data) === null || _data$context$data3 === void 0 ? void 0 : _data$context$data3.message) || ''
|
759
908
|
});
|
760
909
|
return;
|
761
910
|
}
|
@@ -764,6 +913,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
764
913
|
key: 'sdk_onLaunch',
|
765
914
|
value: Date.now()
|
766
915
|
});
|
916
|
+
this.AMSSDK.logger.logInfo({
|
917
|
+
title: 'sdk_event_webAppOnLaunch'
|
918
|
+
}).send();
|
767
919
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
768
920
|
this.sendRenderEvent();
|
769
921
|
return;
|
@@ -814,8 +966,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
814
966
|
}, {
|
815
967
|
key: "handleSizeChanged",
|
816
968
|
value: function handleSizeChanged(data) {
|
817
|
-
var _data$context$
|
818
|
-
if (((_data$context$
|
969
|
+
var _data$context$data4;
|
970
|
+
if (((_data$context$data4 = data.context.data) === null || _data$context$data4 === void 0 ? void 0 : _data$context$data4.height) <= 1) return;
|
819
971
|
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
820
972
|
cashier.style.height = "".concat(data.context.data.height, "px");
|
821
973
|
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
@@ -1004,8 +1156,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1004
1156
|
if (targetElement && targetElement.contentWindow) {
|
1005
1157
|
return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
|
1006
1158
|
}
|
1007
|
-
if (this.app
|
1008
|
-
|
1159
|
+
if (this.app || this.popupApp) {
|
1160
|
+
var _this$app, _this$app2, _this$popupApp, _this$popupApp2;
|
1161
|
+
(this === null || this === void 0 || (_this$app = this.app) === null || _this$app === void 0 ? void 0 : _this$app.contentWindow) && (this === null || this === void 0 || (_this$app2 = this.app) === null || _this$app2 === void 0 ? void 0 : _this$app2.contentWindow.postMessage(JSON.stringify(data), this.appDomain));
|
1162
|
+
(this === null || this === void 0 || (_this$popupApp = this.popupApp) === null || _this$popupApp === void 0 ? void 0 : _this$popupApp.contentWindow) && (this === null || this === void 0 || (_this$popupApp2 = this.popupApp) === null || _this$popupApp2 === void 0 ? void 0 : _this$popupApp2.contentWindow.postMessage(JSON.stringify(data), '*'));
|
1163
|
+
return;
|
1009
1164
|
}
|
1010
1165
|
throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
|
1011
1166
|
}
|
@@ -1030,27 +1185,27 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1030
1185
|
*/
|
1031
1186
|
}, {
|
1032
1187
|
key: "sendRenderEvent",
|
1033
|
-
value: function () {
|
1034
|
-
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
1188
|
+
value: (function () {
|
1189
|
+
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
1035
1190
|
var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
|
1036
|
-
return _regeneratorRuntime().wrap(function
|
1037
|
-
while (1) switch (
|
1191
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
1192
|
+
while (1) switch (_context8.prev = _context8.next) {
|
1038
1193
|
case 0:
|
1039
|
-
|
1194
|
+
_context8.prev = 0;
|
1040
1195
|
if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
|
1041
|
-
|
1196
|
+
_context8.next = 3;
|
1042
1197
|
break;
|
1043
1198
|
}
|
1044
|
-
return
|
1199
|
+
return _context8.abrupt("return");
|
1045
1200
|
case 3:
|
1046
|
-
|
1201
|
+
_context8.next = 5;
|
1047
1202
|
return this._actionQueryPromise;
|
1048
1203
|
case 5:
|
1049
|
-
res =
|
1050
|
-
|
1204
|
+
res = _context8.sent;
|
1205
|
+
_context8.next = 8;
|
1051
1206
|
return this._actionSubmitPromise;
|
1052
1207
|
case 8:
|
1053
|
-
submitRes =
|
1208
|
+
submitRes = _context8.sent;
|
1054
1209
|
this._performanceData.push({
|
1055
1210
|
key: 'sdk_render_component',
|
1056
1211
|
value: Date.now()
|
@@ -1083,16 +1238,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1083
1238
|
}
|
1084
1239
|
});
|
1085
1240
|
// eslint-disable-next-line no-empty
|
1086
|
-
|
1241
|
+
_context8.next = 16;
|
1087
1242
|
break;
|
1088
1243
|
case 14:
|
1089
|
-
|
1090
|
-
|
1244
|
+
_context8.prev = 14;
|
1245
|
+
_context8.t0 = _context8["catch"](0);
|
1091
1246
|
case 16:
|
1092
1247
|
case "end":
|
1093
|
-
return
|
1248
|
+
return _context8.stop();
|
1094
1249
|
}
|
1095
|
-
},
|
1250
|
+
}, _callee8, this, [[0, 14]]);
|
1096
1251
|
}));
|
1097
1252
|
function sendRenderEvent() {
|
1098
1253
|
return _sendRenderEvent.apply(this, arguments);
|
@@ -1102,6 +1257,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1102
1257
|
/**
|
1103
1258
|
* @description close cashier
|
1104
1259
|
*/
|
1260
|
+
)
|
1105
1261
|
}, {
|
1106
1262
|
key: "cleanContainer",
|
1107
1263
|
value: function cleanContainer() {
|
@@ -1,6 +1,8 @@
|
|
1
1
|
export declare const insertStyleSheet: () => void;
|
2
|
-
export declare const createModal: ({ device, url }: {
|
2
|
+
export declare const createModal: ({ device, url, widthPadding, heightPadding }: {
|
3
3
|
device: any;
|
4
4
|
url: any;
|
5
|
-
|
5
|
+
widthPadding: any;
|
6
|
+
heightPadding: any;
|
7
|
+
}) => Promise<HTMLIFrameElement>;
|
6
8
|
export declare const destroyModal: () => void;
|