@alipay/ams-checkout 0.0.1699585541-dev.8 → 0.0.1699863258-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/config/index.d.ts +1 -0
- package/esm/config/index.js +8 -0
- package/esm/core/component/index.d.ts +3 -1
- package/esm/core/component/index.js +10 -3
- package/esm/core/instance/index.d.ts +23 -10
- package/esm/core/instance/index.js +136 -57
- package/esm/index.d.ts +9 -0
- package/esm/index.js +27 -0
- package/esm/plugin/component/cashierApp.js +2 -1
- package/esm/plugin/component/index.d.ts +1 -3
- package/esm/plugin/component/index.js +144 -195
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +6 -9
- package/esm/request/utils.js +1 -4
- package/esm/service/index.d.ts +3 -3
- package/esm/service/index.js +29 -15
- package/esm/types/index.d.ts +21 -63
- package/esm/types/index.js +1 -11
- package/esm/util/index.d.ts +6 -21
- package/esm/util/index.js +38 -45
- package/esm/util/security.d.ts +24 -8
- package/esm/util/security.js +165 -112
- package/esm/util/versionCompare.d.ts +10 -0
- package/esm/util/versionCompare.js +50 -0
- package/package.json +1 -1
@@ -17,11 +17,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
18
18
|
import { marmotMap } from "../../config/index";
|
19
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";
|
20
|
-
import { queryPaymentInfo
|
21
|
-
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum,
|
20
|
+
import { queryPaymentInfo } from "../../service";
|
21
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
|
22
22
|
import { getType, isJsonString, isPC } from "../../util";
|
23
23
|
import { isLocalMock } from "../../util/mock";
|
24
|
-
import { getApdidToken, getAppname, getSecurityHost, initSecuritySDK } from "../../util/security";
|
25
24
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
26
25
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
27
26
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
@@ -44,12 +43,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
44
43
|
_defineProperty(this, "_appVersion", void 0);
|
45
44
|
_defineProperty(this, "_isRetention", void 0);
|
46
45
|
_defineProperty(this, "_actionQueryPromise", null);
|
47
|
-
_defineProperty(this, "_actionSubmitPromise", null);
|
48
46
|
_defineProperty(this, "_renderParams", null);
|
49
47
|
_defineProperty(this, "_componentSign", componentSignEnum.NONE);
|
50
48
|
_defineProperty(this, "_appLocationSearch", void 0);
|
51
49
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
52
|
-
this._appVersion = '1.6.
|
50
|
+
this._appVersion = '1.6.2';
|
53
51
|
this._isInitComponent = false;
|
54
52
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
55
53
|
this.createIframeNode = function () {
|
@@ -86,7 +84,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
86
84
|
key: "initLoggerMeta",
|
87
85
|
value: function initLoggerMeta() {
|
88
86
|
var _this$_renderParams, _paymentSessionMetaDa;
|
89
|
-
console.log('this._renderParams', JSON.stringify(this._renderParams), null, 3);
|
90
87
|
var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
|
91
88
|
var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
|
92
89
|
this.AMSSDK.logger.setMedta({
|
@@ -115,39 +112,39 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
115
112
|
this.createIframeNode = renderFunc;
|
116
113
|
}
|
117
114
|
}, {
|
118
|
-
key: "
|
119
|
-
value: function
|
115
|
+
key: "initSecurity",
|
116
|
+
value: function initSecurity() {
|
120
117
|
var _this$_renderParams2,
|
121
118
|
_this = this;
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
|
130
|
-
var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
|
131
|
-
|
132
|
-
// if merchant have init securitySDK and same as service paymentSessionMetaData, no need init again
|
133
|
-
if (this.AMSSDK.securityConfig) {
|
134
|
-
if (appName === getAppname(this.AMSSDK.securityConfig.scene) && h5gateway === getSecurityHost(this.AMSSDK.securityConfig.region)) {
|
135
|
-
return;
|
136
|
-
}
|
119
|
+
var product = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionConfig) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.productScene;
|
120
|
+
if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
|
121
|
+
this.AMSSDK.logger.logInfo({
|
122
|
+
title: 'sdk_event_security_unneeded_scenarios'
|
123
|
+
}, {
|
124
|
+
product: product
|
125
|
+
});
|
137
126
|
}
|
138
|
-
this.AMSSDK.
|
139
|
-
|
127
|
+
var securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
|
128
|
+
product: product
|
140
129
|
});
|
141
|
-
|
142
|
-
|
143
|
-
title: '
|
130
|
+
if (!securitySDK) {
|
131
|
+
this.AMSSDK.logger.logInfo({
|
132
|
+
title: 'sdk_event_securitySdkInit'
|
144
133
|
});
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
134
|
+
this.AMSSDK._newSecuritySDKByScene({
|
135
|
+
product: product
|
136
|
+
}, function () {
|
137
|
+
_this.AMSSDK.logger.logInfo({
|
138
|
+
title: 'sdk_event_securitySdkInitSuccess'
|
139
|
+
});
|
140
|
+
}, function () {
|
141
|
+
_this.AMSSDK.logger.logError({
|
142
|
+
title: 'sdk_error_securitySdkInitFailed'
|
143
|
+
}, {
|
144
|
+
sign: 'SDK internal initialization'
|
145
|
+
});
|
149
146
|
});
|
150
|
-
}
|
147
|
+
}
|
151
148
|
}
|
152
149
|
}, {
|
153
150
|
key: "logDeviceId",
|
@@ -171,25 +168,49 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
171
168
|
}
|
172
169
|
}, {
|
173
170
|
key: "getDeviceIdAndLog",
|
174
|
-
value: function getDeviceIdAndLog(
|
171
|
+
value: function getDeviceIdAndLog() {
|
175
172
|
var _this2 = this;
|
173
|
+
var deviceIdParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
174
|
+
var isPolling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
176
175
|
return new Promise(function (resolve) {
|
177
176
|
// To avoid rendering being blocked, move the logic to the next event loop for processing
|
178
177
|
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
179
178
|
var _this2$_renderParams;
|
180
|
-
var
|
179
|
+
var productScene, getDeviceIdStartTime, securitySDK, deviceId;
|
181
180
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
182
181
|
while (1) switch (_context.prev = _context.next) {
|
183
182
|
case 0:
|
184
|
-
|
183
|
+
productScene = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionConfig) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.productScene;
|
185
184
|
getDeviceIdStartTime = Date.now();
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
deviceId =
|
185
|
+
securitySDK = _this2.AMSSDK._getSecuritySDKByProductScene({
|
186
|
+
product: (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || productScene
|
187
|
+
});
|
188
|
+
deviceId = '';
|
189
|
+
if (!securitySDK) {
|
190
|
+
_context.next = 16;
|
191
|
+
break;
|
192
|
+
}
|
193
|
+
if (!(isPolling && parseInt(deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.tokenCollectTime) > 0)) {
|
194
|
+
_context.next = 11;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
_context.next = 8;
|
198
|
+
return securitySDK.pollingGetApdidToken(deviceIdParameter);
|
199
|
+
case 8:
|
200
|
+
_context.t0 = _context.sent;
|
201
|
+
_context.next = 14;
|
202
|
+
break;
|
203
|
+
case 11:
|
204
|
+
_context.next = 13;
|
205
|
+
return securitySDK.getApdidToken();
|
206
|
+
case 13:
|
207
|
+
_context.t0 = _context.sent;
|
208
|
+
case 14:
|
209
|
+
deviceId = _context.t0;
|
190
210
|
_this2.logDeviceId(deviceId, getDeviceIdStartTime);
|
211
|
+
case 16:
|
191
212
|
resolve(deviceId);
|
192
|
-
case
|
213
|
+
case 17:
|
193
214
|
case "end":
|
194
215
|
return _context.stop();
|
195
216
|
}
|
@@ -215,7 +236,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
215
236
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
216
237
|
this._renderDisplayType = renderParams.renderDisplayType;
|
217
238
|
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
218
|
-
this.
|
239
|
+
this.initSecurity();
|
219
240
|
this.initLoggerMeta();
|
220
241
|
this._performanceData.push({
|
221
242
|
key: 'sdk_create_component',
|
@@ -236,7 +257,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
236
257
|
this.renderPopupLoading(renderParams);
|
237
258
|
}
|
238
259
|
this.createApp(renderParams);
|
239
|
-
return Promise.all([this.createActionQueryPromise(), this.
|
260
|
+
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
|
240
261
|
_this3.AMSSDK.logger.logInfo({
|
241
262
|
title: 'sdk_event_successfully_created_app_process'
|
242
263
|
}).send();
|
@@ -302,8 +323,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
302
323
|
// eslint-disable-next-line no-async-promise-executor
|
303
324
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
304
325
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
305
|
-
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3
|
306
|
-
var envInfo, params,
|
326
|
+
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3;
|
327
|
+
var envInfo, params, _this5$_renderParams4, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams5, _action$web, _action$wap, action, signType;
|
307
328
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
308
329
|
while (1) switch (_context2.prev = _context2.next) {
|
309
330
|
case 0:
|
@@ -315,78 +336,71 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
315
336
|
paymentSessionConfig: (_this5$_renderParams2 = _this5._renderParams) === null || _this5$_renderParams2 === void 0 || (_this5$_renderParams2 = _this5$_renderParams2.paymentSessionMetaData) === null || _this5$_renderParams2 === void 0 ? void 0 : _this5$_renderParams2.paymentSessionConfig,
|
316
337
|
notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true
|
317
338
|
};
|
318
|
-
/**
|
319
|
-
* @description Simulated or unnecessary scenarios
|
320
|
-
*/
|
321
|
-
if (!(isLocalMock() || (_this5$_renderParams4 = _this5._renderParams) !== null && _this5$_renderParams4 !== void 0 && (_this5$_renderParams4 = _this5$_renderParams4.paymentSessionMetaData) !== null && _this5$_renderParams4 !== void 0 && _this5$_renderParams4.action.skipSdkQuery)) {
|
322
|
-
_context2.next = 4;
|
323
|
-
break;
|
324
|
-
}
|
325
|
-
return _context2.abrupt("return", resolve({
|
326
|
-
message: 'sdk no need to make query request',
|
327
|
-
success: true
|
328
|
-
}));
|
329
|
-
case 4:
|
330
339
|
/**
|
331
340
|
* @description card
|
332
341
|
*/
|
333
|
-
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign) {
|
334
|
-
|
335
|
-
}
|
336
|
-
securityConfig = (_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.securityConfig;
|
337
|
-
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign && securityConfig)) {
|
338
|
-
_context2.next = 13;
|
342
|
+
if (!(componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || componentSignEnum.VAULTING_CARD === _this5._componentSign)) {
|
343
|
+
_context2.next = 7;
|
339
344
|
break;
|
340
345
|
}
|
341
|
-
|
342
|
-
|
343
|
-
if (!((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false')) {
|
344
|
-
_context2.next = 13;
|
345
|
-
break;
|
346
|
-
}
|
347
|
-
_context2.next = 12;
|
346
|
+
params.paymentMethodType = 'CARD';
|
347
|
+
_context2.next = 6;
|
348
348
|
return _this5.getDeviceIdAndLog();
|
349
|
-
case
|
349
|
+
case 6:
|
350
350
|
envInfo.deviceId = _context2.sent;
|
351
|
-
case
|
351
|
+
case 7:
|
352
352
|
if (!(componentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
|
353
|
-
_context2.next =
|
353
|
+
_context2.next = 15;
|
354
354
|
break;
|
355
355
|
}
|
356
356
|
_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;
|
357
|
-
_ref4 = ((_this5$
|
357
|
+
_ref4 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.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;
|
358
358
|
if (!(productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken)) {
|
359
|
-
_context2.next =
|
359
|
+
_context2.next = 12;
|
360
360
|
break;
|
361
361
|
}
|
362
362
|
return _context2.abrupt("return", resolve({
|
363
363
|
message: 'sdk no need to make query request',
|
364
364
|
success: true
|
365
365
|
}));
|
366
|
-
case
|
366
|
+
case 12:
|
367
|
+
_context2.next = 14;
|
368
|
+
return _this5.getDeviceIdAndLog();
|
369
|
+
case 14:
|
370
|
+
envInfo.deviceId = _context2.sent;
|
371
|
+
case 15:
|
367
372
|
if (!(componentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
|
368
|
-
_context2.next =
|
373
|
+
_context2.next = 22;
|
369
374
|
break;
|
370
375
|
}
|
371
|
-
action = ((_this5$
|
376
|
+
action = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action) || {};
|
372
377
|
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;
|
373
378
|
if (!(signType === 'SMS')) {
|
374
|
-
_context2.next =
|
379
|
+
_context2.next = 20;
|
375
380
|
break;
|
376
381
|
}
|
377
382
|
return _context2.abrupt("return", resolve({
|
378
383
|
message: 'sdk no need to make query request',
|
379
384
|
success: true
|
380
385
|
}));
|
381
|
-
case
|
386
|
+
case 20:
|
382
387
|
if (!(!signType || signType !== 'REDIRECT')) {
|
383
|
-
_context2.next =
|
388
|
+
_context2.next = 22;
|
384
389
|
break;
|
385
390
|
}
|
386
391
|
return _context2.abrupt("return", resolve({
|
387
392
|
success: false
|
388
393
|
}));
|
389
|
-
case
|
394
|
+
case 22:
|
395
|
+
if (!isLocalMock()) {
|
396
|
+
_context2.next = 24;
|
397
|
+
break;
|
398
|
+
}
|
399
|
+
return _context2.abrupt("return", resolve({
|
400
|
+
message: 'sdk no need to make query request',
|
401
|
+
success: true
|
402
|
+
}));
|
403
|
+
case 24:
|
390
404
|
queryPaymentInfo(params, {
|
391
405
|
env: _this5.AMSSDK.options.env.environment,
|
392
406
|
envInfo: envInfo
|
@@ -411,7 +425,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
411
425
|
});
|
412
426
|
reject(err);
|
413
427
|
});
|
414
|
-
case
|
428
|
+
case 25:
|
415
429
|
case "end":
|
416
430
|
return _context2.stop();
|
417
431
|
}
|
@@ -423,66 +437,6 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
423
437
|
}());
|
424
438
|
return this._actionQueryPromise;
|
425
439
|
}
|
426
|
-
}, {
|
427
|
-
key: "createSubmitPromise",
|
428
|
-
value: function createSubmitPromise() {
|
429
|
-
var _this$_renderParams3,
|
430
|
-
_this$_renderParams4,
|
431
|
-
_this6 = this;
|
432
|
-
this._performanceData.push({
|
433
|
-
key: 'sdk_submit_start',
|
434
|
-
value: Date.now()
|
435
|
-
});
|
436
|
-
var params = {
|
437
|
-
paymentSessionData: this._renderParams && ((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData) || '',
|
438
|
-
paymentSessionConfig: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionConfig
|
439
|
-
};
|
440
|
-
|
441
|
-
// eslint-disable-next-line no-async-promise-executor
|
442
|
-
this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
|
443
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
444
|
-
var _this6$_renderParams;
|
445
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
446
|
-
while (1) switch (_context3.prev = _context3.next) {
|
447
|
-
case 0:
|
448
|
-
if (!(!((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.action.skipSdkQuery) || componentSignEnum.EASY_PAY_WALLET !== _this6._componentSign)) {
|
449
|
-
_context3.next = 2;
|
450
|
-
break;
|
451
|
-
}
|
452
|
-
return _context3.abrupt("return", resolve({
|
453
|
-
message: 'sdk no need to make submitPay request',
|
454
|
-
success: true
|
455
|
-
}));
|
456
|
-
case 2:
|
457
|
-
submitPayInfo(params, {
|
458
|
-
env: _this6.AMSSDK.options.env.environment,
|
459
|
-
timeout: 15000
|
460
|
-
}, _this6.AMSSDK.logger).then(function (res) {
|
461
|
-
_this6._performanceData.push({
|
462
|
-
key: 'sdk_submit_end',
|
463
|
-
value: Date.now()
|
464
|
-
});
|
465
|
-
if (res !== null && res !== void 0 && res.success) {
|
466
|
-
resolve(res);
|
467
|
-
} else {
|
468
|
-
resolve(res);
|
469
|
-
}
|
470
|
-
}).catch(function () {
|
471
|
-
return resolve({
|
472
|
-
success: false
|
473
|
-
});
|
474
|
-
});
|
475
|
-
case 3:
|
476
|
-
case "end":
|
477
|
-
return _context3.stop();
|
478
|
-
}
|
479
|
-
}, _callee3);
|
480
|
-
}));
|
481
|
-
return function (_x3) {
|
482
|
-
return _ref5.apply(this, arguments);
|
483
|
-
};
|
484
|
-
}());
|
485
|
-
}
|
486
440
|
}, {
|
487
441
|
key: "cleanElement",
|
488
442
|
value: function cleanElement() {
|
@@ -599,9 +553,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
599
553
|
}, {
|
600
554
|
key: "createPopupWindow",
|
601
555
|
value: function createPopupWindow(data) {
|
602
|
-
var _this$
|
556
|
+
var _this$_renderParams3;
|
603
557
|
this._threedData = data;
|
604
|
-
var sessionData = encodeURIComponent((_this$
|
558
|
+
var sessionData = encodeURIComponent((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData);
|
605
559
|
var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&").concat(this._appLocationSearch);
|
606
560
|
this.popupWindow = createModal({
|
607
561
|
device: this.platform,
|
@@ -611,19 +565,19 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
611
565
|
}, {
|
612
566
|
key: "getDeviceIdAndCallback",
|
613
567
|
value: function () {
|
614
|
-
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
568
|
+
var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventContext) {
|
615
569
|
var deviceId;
|
616
|
-
return _regeneratorRuntime().wrap(function
|
617
|
-
while (1) switch (
|
570
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
571
|
+
while (1) switch (_context3.prev = _context3.next) {
|
618
572
|
case 0:
|
619
573
|
if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
|
620
|
-
|
574
|
+
_context3.next = 5;
|
621
575
|
break;
|
622
576
|
}
|
623
|
-
|
624
|
-
return this.getDeviceIdAndLog();
|
577
|
+
_context3.next = 3;
|
578
|
+
return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
|
625
579
|
case 3:
|
626
|
-
deviceId =
|
580
|
+
deviceId = _context3.sent;
|
627
581
|
this.dispatchToApp({
|
628
582
|
context: {
|
629
583
|
event: 'appEventCallback',
|
@@ -635,11 +589,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
635
589
|
});
|
636
590
|
case 5:
|
637
591
|
case "end":
|
638
|
-
return
|
592
|
+
return _context3.stop();
|
639
593
|
}
|
640
|
-
},
|
594
|
+
}, _callee3, this);
|
641
595
|
}));
|
642
|
-
function getDeviceIdAndCallback(
|
596
|
+
function getDeviceIdAndCallback(_x3) {
|
643
597
|
return _getDeviceIdAndCallback.apply(this, arguments);
|
644
598
|
}
|
645
599
|
return getDeviceIdAndCallback;
|
@@ -804,7 +758,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
804
758
|
}, {
|
805
759
|
key: "handleRedirect",
|
806
760
|
value: function handleRedirect(data) {
|
807
|
-
var
|
761
|
+
var _this6 = this;
|
808
762
|
var _data = typeof data === 'string' ? {
|
809
763
|
normalUrl: data
|
810
764
|
} : {
|
@@ -819,11 +773,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
819
773
|
redirectInfo: JSON.stringify(_data)
|
820
774
|
}).send();
|
821
775
|
var successCallback = function successCallback(type, url) {
|
822
|
-
|
776
|
+
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
823
777
|
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
|
824
778
|
message: "Successfully opened the app,".concat(type, ": ").concat(url)
|
825
779
|
});
|
826
|
-
|
780
|
+
_this6.AMSSDK.logger.logInfo({
|
827
781
|
title: 'sdk_event_call_url_success'
|
828
782
|
}, {
|
829
783
|
redirectInfo: JSON.stringify(_data),
|
@@ -832,11 +786,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
832
786
|
}).send();
|
833
787
|
};
|
834
788
|
var failCallback = function failCallback(type, url) {
|
835
|
-
|
836
|
-
code: eventCodeEnum.
|
789
|
+
_this6.dispatchToSDK(EVENT.eventCallback.name, {
|
790
|
+
code: eventCodeEnum.SDK_CALL_URL_ERROR,
|
837
791
|
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
|
838
792
|
});
|
839
|
-
|
793
|
+
_this6.AMSSDK.logger.logInfo({
|
840
794
|
title: 'sdk_error_call_url_failed'
|
841
795
|
}, {
|
842
796
|
redirectInfo: JSON.stringify(_data),
|
@@ -859,14 +813,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
859
813
|
successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
860
814
|
}).catch(function () {
|
861
815
|
failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
|
862
|
-
return
|
816
|
+
return _this6.AMSSDK._redirect({
|
863
817
|
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
|
864
818
|
});
|
865
819
|
}).then(function () {
|
866
820
|
successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
867
821
|
}).catch(function () {
|
868
822
|
failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
|
869
|
-
return
|
823
|
+
return _this6.AMSSDK._redirect({
|
870
824
|
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
|
871
825
|
});
|
872
826
|
}).then(function () {
|
@@ -877,9 +831,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
877
831
|
}
|
878
832
|
}, {
|
879
833
|
key: "handleDeclareInfo",
|
880
|
-
value: function handleDeclareInfo(
|
881
|
-
var
|
882
|
-
closeDialogData =
|
834
|
+
value: function handleDeclareInfo(_ref5) {
|
835
|
+
var _ref5$closeDialogData = _ref5.closeDialogData,
|
836
|
+
closeDialogData = _ref5$closeDialogData === void 0 ? {} : _ref5$closeDialogData;
|
883
837
|
_handleDeclareInfo({
|
884
838
|
closeDialogData: closeDialogData
|
885
839
|
});
|
@@ -953,26 +907,22 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
953
907
|
}, {
|
954
908
|
key: "sendRenderEvent",
|
955
909
|
value: function () {
|
956
|
-
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
957
|
-
var _this$
|
958
|
-
return _regeneratorRuntime().wrap(function
|
959
|
-
while (1) switch (
|
910
|
+
var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
911
|
+
var _this$_renderParams4, _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, res;
|
912
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
913
|
+
while (1) switch (_context4.prev = _context4.next) {
|
960
914
|
case 0:
|
961
|
-
|
962
|
-
if (
|
963
|
-
|
915
|
+
_context4.prev = 0;
|
916
|
+
if (this._actionQueryPromise) {
|
917
|
+
_context4.next = 3;
|
964
918
|
break;
|
965
919
|
}
|
966
|
-
return
|
920
|
+
return _context4.abrupt("return");
|
967
921
|
case 3:
|
968
|
-
|
922
|
+
_context4.next = 5;
|
969
923
|
return this._actionQueryPromise;
|
970
924
|
case 5:
|
971
|
-
res =
|
972
|
-
_context5.next = 8;
|
973
|
-
return this._actionSubmitPromise;
|
974
|
-
case 8:
|
975
|
-
submitRes = _context5.sent;
|
925
|
+
res = _context4.sent;
|
976
926
|
this._performanceData.push({
|
977
927
|
key: 'sdk_render_component',
|
978
928
|
value: Date.now()
|
@@ -982,13 +932,12 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
982
932
|
event: 'renderComponent',
|
983
933
|
data: {
|
984
934
|
queryResult: res,
|
985
|
-
|
986
|
-
|
987
|
-
paymentSessionData: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.sessionData,
|
935
|
+
sessionResult: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionMetaData,
|
936
|
+
paymentSessionData: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData,
|
988
937
|
heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
|
989
|
-
renderDisplayType: (_this$
|
990
|
-
appearance: (_this$
|
991
|
-
notRedirectAfterComplete: ((_this$
|
938
|
+
renderDisplayType: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.renderDisplayType,
|
939
|
+
appearance: (_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.appearance,
|
940
|
+
notRedirectAfterComplete: ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.notRedirectAfterComplete) === true,
|
992
941
|
envInfo: {
|
993
942
|
screenHeight: screen.height,
|
994
943
|
screenWidth: screen.width
|
@@ -1005,16 +954,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1005
954
|
}
|
1006
955
|
});
|
1007
956
|
// eslint-disable-next-line no-empty
|
1008
|
-
|
957
|
+
_context4.next = 13;
|
1009
958
|
break;
|
1010
|
-
case
|
1011
|
-
|
1012
|
-
|
1013
|
-
case
|
959
|
+
case 11:
|
960
|
+
_context4.prev = 11;
|
961
|
+
_context4.t0 = _context4["catch"](0);
|
962
|
+
case 13:
|
1014
963
|
case "end":
|
1015
|
-
return
|
964
|
+
return _context4.stop();
|
1016
965
|
}
|
1017
|
-
},
|
966
|
+
}, _callee4, this, [[0, 11]]);
|
1018
967
|
}));
|
1019
968
|
function sendRenderEvent() {
|
1020
969
|
return _sendRenderEvent.apply(this, arguments);
|
@@ -1028,7 +977,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1028
977
|
key: "cleanContainer",
|
1029
978
|
value: function cleanContainer() {
|
1030
979
|
var _document$getElementB4,
|
1031
|
-
|
980
|
+
_this7 = this;
|
1032
981
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1033
982
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
1034
983
|
this._performanceData = [];
|
@@ -1040,7 +989,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1040
989
|
mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
1041
990
|
if (immediately) this.cleanElement();else {
|
1042
991
|
setTimeout(function () {
|
1043
|
-
|
992
|
+
_this7.cleanElement();
|
1044
993
|
}, 300);
|
1045
994
|
}
|
1046
995
|
}
|
package/esm/request/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { IrequestConfig } from '../types';
|
2
2
|
import { Logger } from '../util/logger';
|
3
3
|
/**
|
4
4
|
*
|
@@ -6,4 +6,4 @@ import { Logger } from '../util/logger';
|
|
6
6
|
* @param options 请求配置
|
7
7
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
8
8
|
*/
|
9
|
-
export declare function request<T>(requestData: Record<string, any> | undefined, options:
|
9
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: IrequestConfig, logger: Logger): Promise<T>;
|