@alipay/ams-checkout 1.11.1 → 1.13.0
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/core/bus/index.d.ts +1 -1
- package/esm/core/bus/interface.d.ts +5 -1
- package/esm/core/bus/interface.js +6 -1
- package/esm/core/component/index.js +10 -4
- package/esm/core/instance/index.d.ts +8 -1
- package/esm/core/instance/index.js +18 -11
- package/esm/plugin/applepay/component.d.ts +1 -1
- package/esm/plugin/applepay/component.js +5 -5
- package/esm/plugin/applepay/index.d.ts +1 -1
- package/esm/plugin/applepay/index.js +6 -6
- package/esm/plugin/component/cashierApp.d.ts +6 -2
- package/esm/plugin/component/cashierApp.js +68 -12
- package/esm/plugin/component/index.js +73 -41
- package/esm/plugin/const.js +18 -4
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +389 -0
- package/esm/plugin/type.d.ts +2 -2
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/types/index.d.ts +53 -3
- package/esm/types/index.js +18 -0
- package/esm/util/debug.d.ts +1 -0
- package/esm/util/debug.js +9 -0
- package/esm/util/index.d.ts +2 -1
- package/esm/util/index.js +4 -2
- package/esm/util/logger.d.ts +8 -0
- package/esm/util/logger.js +34 -3
- package/esm/util/storage.d.ts +2 -0
- package/esm/util/storage.js +23 -0
- package/esm/util/upgrade.d.ts +39 -0
- package/esm/util/upgrade.js +115 -0
- package/esm/util/versionCompare.d.ts +8 -1
- package/esm/util/versionCompare.js +22 -0
- package/package.json +1 -1
package/esm/core/bus/index.d.ts
CHANGED
@@ -4,7 +4,11 @@ export declare enum PaymentActionEnum {
|
|
4
4
|
export declare enum ApplePayActionEnum {
|
5
5
|
canMakePayments = "plugin_CARD_APPLE_PAY_available",
|
6
6
|
createComponent = "plugin_CARD_APPLE_PAY_createComponent",
|
7
|
-
|
7
|
+
destroyComponent = "plugin_CARD_APPLE_PAY_destroyComponent"
|
8
|
+
}
|
9
|
+
export declare enum PaypalActionEnum {
|
10
|
+
mountComponent = "plugin_Paypal_mountComponent",
|
11
|
+
destroyComponent = "plugin_Paypal_destroyComponent"
|
8
12
|
}
|
9
13
|
export declare enum SDKCallbackActionEnum {
|
10
14
|
onEventCallback = "onEventCallback"
|
@@ -5,9 +5,14 @@ export var PaymentActionEnum = /*#__PURE__*/function (PaymentActionEnum) {
|
|
5
5
|
export var ApplePayActionEnum = /*#__PURE__*/function (ApplePayActionEnum) {
|
6
6
|
ApplePayActionEnum["canMakePayments"] = "plugin_CARD_APPLE_PAY_available";
|
7
7
|
ApplePayActionEnum["createComponent"] = "plugin_CARD_APPLE_PAY_createComponent";
|
8
|
-
ApplePayActionEnum["
|
8
|
+
ApplePayActionEnum["destroyComponent"] = "plugin_CARD_APPLE_PAY_destroyComponent";
|
9
9
|
return ApplePayActionEnum;
|
10
10
|
}({});
|
11
|
+
export var PaypalActionEnum = /*#__PURE__*/function (PaypalActionEnum) {
|
12
|
+
PaypalActionEnum["mountComponent"] = "plugin_Paypal_mountComponent";
|
13
|
+
PaypalActionEnum["destroyComponent"] = "plugin_Paypal_destroyComponent";
|
14
|
+
return PaypalActionEnum;
|
15
|
+
}({});
|
11
16
|
export var SDKCallbackActionEnum = /*#__PURE__*/function (SDKCallbackActionEnum) {
|
12
17
|
SDKCallbackActionEnum["onEventCallback"] = "onEventCallback";
|
13
18
|
return SDKCallbackActionEnum;
|
@@ -29,18 +29,19 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
29
|
*/
|
30
30
|
import { v4 as uuid } from 'uuid';
|
31
31
|
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
|
32
|
+
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
32
33
|
import ComponentApp from "../../plugin/component";
|
34
|
+
import { ExtendPlugin } from "../../plugin/const";
|
35
|
+
import { PaypalBusSubscriber } from "../../plugin/paypal";
|
33
36
|
import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
|
34
37
|
import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
|
35
38
|
import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
|
36
39
|
import { getSecurityConfigStorageKey } from "../../util/security";
|
37
|
-
import CoreInstance from "../instance/index";
|
38
40
|
import { BusManager, BusMessage } from "../bus";
|
39
41
|
import { SDKCallbackBusSubscriber } from "../bus/ability/callback";
|
40
|
-
import { ApplePayBusSubscriber } from "../../plugin/applepay";
|
41
42
|
import { SecurityBusSubscriber } from "../bus/ability/security";
|
42
43
|
import { TrackerBusSubscriber } from "../bus/ability/tracker";
|
43
|
-
import
|
44
|
+
import CoreInstance from "../instance/index";
|
44
45
|
export var getComponentSign = function getComponentSign(params) {
|
45
46
|
var _params$paymentSessio = params.paymentSessionConfig,
|
46
47
|
_params$paymentSessio2 = _params$paymentSessio === void 0 ? {} : _params$paymentSessio,
|
@@ -230,6 +231,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
230
231
|
BusManager.subscribe(new TrackerBusSubscriber(this.logger));
|
231
232
|
// subscribe plugin
|
232
233
|
BusManager.subscribe(new ApplePayBusSubscriber(this.logger));
|
234
|
+
BusManager.subscribe(new PaypalBusSubscriber(this.logger));
|
233
235
|
|
234
236
|
// register bus plugin
|
235
237
|
ExtendPlugin.forEach(function (item) {
|
@@ -265,7 +267,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
265
267
|
* only the channel described in the document will be called, and it will be returned as available by default
|
266
268
|
* @param paymentMethod - described in the document
|
267
269
|
* @param subPaymentMethod - described in the document
|
268
|
-
* @returns
|
270
|
+
* @returns
|
269
271
|
*/
|
270
272
|
}, {
|
271
273
|
key: "canMakePayments",
|
@@ -323,6 +325,8 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
323
325
|
_this4._eventCenter.emit(EVENT.error.name, error);
|
324
326
|
return Promise.reject(error);
|
325
327
|
}).then(function (appendParams) {
|
328
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
329
|
+
_this4.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
326
330
|
return _this4.createComponentProcess(appendParams);
|
327
331
|
});
|
328
332
|
}
|
@@ -412,6 +416,8 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
412
416
|
_this6._eventCenter.emit(EVENT.error.name, error);
|
413
417
|
return Promise.reject(error);
|
414
418
|
}).then(function (appendParams) {
|
419
|
+
var iframeNodesParams = appendParams.iframeNodesParams;
|
420
|
+
_this6.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
|
415
421
|
return _this6.mountComponentProcess(appendParams);
|
416
422
|
});
|
417
423
|
}
|
@@ -1,8 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
*
|
4
|
+
* 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:
|
5
|
+
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
|
+
* 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.
|
7
|
+
*/
|
8
|
+
import { ComponentActionNamesType } from 'src/plugin/type';
|
1
9
|
import type { AMSCheckoutOptions, IAppendParams, InitSecurityConfig, IoptionsParams } from '../../types/index';
|
2
10
|
import { EventCenter } from '../../util/index';
|
3
11
|
import { Logger } from '../../util/logger';
|
4
12
|
import { Security } from '../../util/security';
|
5
|
-
import { ComponentActionNamesType } from 'src/plugin/type';
|
6
13
|
export default class AMSSDK {
|
7
14
|
options: AMSCheckoutOptions;
|
8
15
|
originOptions: IoptionsParams;
|
@@ -16,6 +16,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
16
16
|
* 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.
|
17
17
|
*/
|
18
18
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
|
+
|
19
20
|
import { v4 as uuid } from 'uuid';
|
20
21
|
import { sdkVersion } from "../../config/index";
|
21
22
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
@@ -24,8 +25,8 @@ import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, productSceneEnu
|
|
24
25
|
import { checkTimeElapsed, device, EventCenter, getOrSetStorageId, getType, queryParse, safeJson } from "../../util/index";
|
25
26
|
import CallApp from "../../util/intl-callapp/es/main";
|
26
27
|
import { LogConfig, Logger } from "../../util/logger";
|
27
|
-
import { compareVersion } from "../../util/versionCompare";
|
28
28
|
import { getSecurityConfigStorageKey, getSecurityHost, getSecurityScene, Security, SecurityRegionEnum } from "../../util/security";
|
29
|
+
import { compareVersion } from "../../util/versionCompare";
|
29
30
|
import { BusManager, BusMessage } from "../bus";
|
30
31
|
var AMSSDK = /*#__PURE__*/function () {
|
31
32
|
function AMSSDK(options) {
|
@@ -57,13 +58,16 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
57
58
|
|
58
59
|
// TODO Consumption data analysis control parameters
|
59
60
|
this.logger = new Logger(LogConfig, ![environmentEnum.prod, environmentEnum.sandbox].includes(options === null || options === void 0 ? void 0 : options.environment));
|
61
|
+
Logger.setInstance(this.logger);
|
60
62
|
this.logger.setMedta({
|
61
63
|
instanceId: this._instanceId
|
62
64
|
});
|
63
65
|
this.logger.initTracker();
|
66
|
+
this.logger.setComponentStartTime(Date.now());
|
67
|
+
this.logger.setTrackId(this._instanceId);
|
64
68
|
this.logger.logInfo({
|
65
69
|
title: 'NEW_AMSSDK_BY_MECHANT',
|
66
|
-
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale
|
70
|
+
msg: "".concat(options === null || options === void 0 ? void 0 : options.environment, "_").concat(options === null || options === void 0 ? void 0 : options.locale)
|
67
71
|
}).send();
|
68
72
|
this.preInitSecurity(options);
|
69
73
|
}
|
@@ -87,7 +91,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
87
91
|
var matchingConfig = config['pl_sec'].find(function (item) {
|
88
92
|
var _item$v, _item$v2, _item$platform;
|
89
93
|
var minVersion = item === null || item === void 0 || (_item$v = item.v) === null || _item$v === void 0 ? void 0 : _item$v.split('|')[0];
|
90
|
-
var maxVersion = (item === null || item === void 0 || (_item$v2 = item.v) === null || _item$v2 === void 0 ? void 0 : _item$v2.split('|')[1]) || '
|
94
|
+
var maxVersion = (item === null || item === void 0 || (_item$v2 = item.v) === null || _item$v2 === void 0 ? void 0 : _item$v2.split('|')[1]) || '999999.9.9';
|
91
95
|
var matchVersion = compareVersion(sdkVersion, minVersion) >= 0 && compareVersion(maxVersion, sdkVersion) >= 0;
|
92
96
|
return ((item === null || item === void 0 || (_item$platform = item.platform) === null || _item$platform === void 0 ? void 0 : _item$platform.includes('Web')) || (item === null || item === void 0 ? void 0 : item.platform) === '') && (item === null || item === void 0 ? void 0 : item.product) === product && (!(item !== null && item !== void 0 && item.v) || matchVersion);
|
93
97
|
});
|
@@ -110,11 +114,13 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
110
114
|
this.logger.logInfo({
|
111
115
|
title: 'sdk_event_apiOnDestroy'
|
112
116
|
}).send();
|
113
|
-
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.
|
117
|
+
var actionName = (_this$getBusActionNam = this.getBusActionNames()) === null || _this$getBusActionNam === void 0 ? void 0 : _this$getBusActionNam.destroyComponent;
|
114
118
|
if (actionName && BusManager.isSubscribed(actionName)) {
|
119
|
+
var _this$_appendParams;
|
115
120
|
// 执行出错了,在通用拦截器返回
|
116
121
|
BusManager.publish(new BusMessage(actionName, JSON.stringify({
|
117
|
-
options: this.originOptions
|
122
|
+
options: this.originOptions,
|
123
|
+
selector: (_this$_appendParams = this._appendParams) === null || _this$_appendParams === void 0 || (_this$_appendParams = _this$_appendParams.iframeNodesParams) === null || _this$_appendParams === void 0 ? void 0 : _this$_appendParams.selector
|
118
124
|
})));
|
119
125
|
}
|
120
126
|
var _iterator = _createForOfIteratorHelper(this.plugins.values()),
|
@@ -316,14 +322,14 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
316
322
|
key: "_registerPlugin",
|
317
323
|
value: function _registerPlugin(pluginId, plugin) {
|
318
324
|
this.plugins.set(pluginId, plugin);
|
319
|
-
|
320
|
-
|
325
|
+
if (plugin !== null && plugin !== void 0 && plugin.applyPlugin) {
|
326
|
+
try {
|
321
327
|
plugin.applyPlugin(this);
|
328
|
+
} catch (error) {
|
329
|
+
this.plugins.delete(pluginId);
|
330
|
+
if (getType(error) === 'error') throw error;
|
331
|
+
throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
|
322
332
|
}
|
323
|
-
} catch (error) {
|
324
|
-
this.plugins.delete(pluginId);
|
325
|
-
if (getType(error) === 'error') throw error;
|
326
|
-
throw new Error("Failed to register plug-in\uFF1A".concat(pluginId, " Exception in the apply function of the plug-in"));
|
327
333
|
}
|
328
334
|
}
|
329
335
|
/**
|
@@ -338,6 +344,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
338
344
|
}
|
339
345
|
return this.plugins.get(pluginId);
|
340
346
|
}
|
347
|
+
|
341
348
|
/**
|
342
349
|
* @description Execute to open app or jump link
|
343
350
|
*/
|
@@ -14,7 +14,7 @@ export declare enum ApplePayComponentEvent {
|
|
14
14
|
sdk_event_appleOnvalidatemerchant = "sdk_event_appleOnvalidatemerchant",
|
15
15
|
sdk_event_appleSubmitToken = "sdk_event_appleSubmitToken",
|
16
16
|
sdk_event_applePaymentResult = "sdk_event_applePaymentResult",
|
17
|
-
|
17
|
+
sdk_event_appleDestroyComponent = "sdk_event_appleDestroyComponent"
|
18
18
|
}
|
19
19
|
/**
|
20
20
|
* Apple pay Component
|
@@ -27,7 +27,7 @@ export var ApplePayComponentEvent = /*#__PURE__*/function (ApplePayComponentEven
|
|
27
27
|
ApplePayComponentEvent["sdk_event_appleOnvalidatemerchant"] = "sdk_event_appleOnvalidatemerchant";
|
28
28
|
ApplePayComponentEvent["sdk_event_appleSubmitToken"] = "sdk_event_appleSubmitToken";
|
29
29
|
ApplePayComponentEvent["sdk_event_applePaymentResult"] = "sdk_event_applePaymentResult";
|
30
|
-
ApplePayComponentEvent["
|
30
|
+
ApplePayComponentEvent["sdk_event_appleDestroyComponent"] = "sdk_event_appleDestroyComponent";
|
31
31
|
return ApplePayComponentEvent;
|
32
32
|
}({});
|
33
33
|
|
@@ -55,8 +55,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
55
55
|
|
56
56
|
/**
|
57
57
|
* Is Apple Pay Enabled
|
58
|
-
* @param subTypeEnum
|
59
|
-
* @returns
|
58
|
+
* @param subTypeEnum
|
59
|
+
* @returns
|
60
60
|
*/
|
61
61
|
_createClass(ApplePayComponent, [{
|
62
62
|
key: "canMakePayments",
|
@@ -66,8 +66,8 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
66
66
|
|
67
67
|
/**
|
68
68
|
* Is Apple Pay Enabled
|
69
|
-
* @param subTypeEnum
|
70
|
-
* @returns
|
69
|
+
* @param subTypeEnum
|
70
|
+
* @returns
|
71
71
|
*/
|
72
72
|
}, {
|
73
73
|
key: "isAppPayEnabled",
|
@@ -12,6 +12,6 @@ export declare class ApplePayBusSubscriber extends BusSubscriber {
|
|
12
12
|
protected onOptionalInit(context: BusContext, message: BusMessage): void;
|
13
13
|
protected onCanMakePayments(context: BusContext, message: BusMessage): void;
|
14
14
|
protected onCreateComponent(context: BusContext, message: BusMessage): void;
|
15
|
-
protected
|
15
|
+
protected onDestroyComponent(context: BusContext, message: BusMessage): void;
|
16
16
|
onMessage(context: BusContext, message: BusMessage): void;
|
17
17
|
}
|
@@ -80,13 +80,13 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
80
80
|
this.applePay.submitPay(appendParams);
|
81
81
|
}
|
82
82
|
}, {
|
83
|
-
key: "
|
84
|
-
value: function
|
83
|
+
key: "onDestroyComponent",
|
84
|
+
value: function onDestroyComponent(context, message) {
|
85
85
|
this.applePay = null;
|
86
|
-
console.log('
|
86
|
+
console.log('onDestroyComponent', context, message);
|
87
87
|
this.logger.logInfo({
|
88
88
|
name: 'APPLE_PAY',
|
89
|
-
title: ApplePayComponentEvent.
|
89
|
+
title: ApplePayComponentEvent.sdk_event_appleDestroyComponent
|
90
90
|
}, {
|
91
91
|
biz: 'sdk',
|
92
92
|
type: 'funnel'
|
@@ -105,8 +105,8 @@ export var ApplePayBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
|
|
105
105
|
case ApplePayActionEnum.createComponent:
|
106
106
|
this.onCreateComponent(context, message);
|
107
107
|
break;
|
108
|
-
case ApplePayActionEnum.
|
109
|
-
this.
|
108
|
+
case ApplePayActionEnum.destroyComponent:
|
109
|
+
this.onDestroyComponent(context, message);
|
110
110
|
break;
|
111
111
|
default:
|
112
112
|
console.log("Unknown action: " + message.getAction());
|
@@ -1,15 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productSceneVersion: string, extendInfo: string) => any;
|
1
|
+
import { componentSignEnum, Ianalytics, renderDisplayTypeEnum } from '../../types';
|
2
|
+
export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productScene: string, productSceneVersion: string, extendInfo: string, mid: string) => any;
|
3
3
|
export declare const getAppDomain: (domainParams: {
|
4
4
|
environment: string;
|
5
5
|
appVersion: string;
|
6
6
|
componentSign: componentSignEnum;
|
7
|
+
productScene: string;
|
7
8
|
productSceneVersion: string;
|
8
9
|
extendInfo: string;
|
10
|
+
mid: string;
|
9
11
|
}) => string;
|
10
12
|
export declare const getIframeUrl: (iframeParams: {
|
11
13
|
componentSign: componentSignEnum;
|
12
14
|
analytics?: Ianalytics;
|
15
|
+
productScene: string;
|
13
16
|
productSceneVersion: string;
|
14
17
|
environment: string;
|
15
18
|
appVersion: string;
|
@@ -19,6 +22,7 @@ export declare const getIframeUrl: (iframeParams: {
|
|
19
22
|
renderDisplayType: renderDisplayTypeEnum;
|
20
23
|
isPreload?: string;
|
21
24
|
hostSign?: string;
|
25
|
+
mid: string;
|
22
26
|
}) => {
|
23
27
|
path: string;
|
24
28
|
locationSearch: string;
|
@@ -10,12 +10,40 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
10
10
|
* 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.
|
11
11
|
*/
|
12
12
|
import { marmotMap, sdkVersion } from "../../config/index";
|
13
|
-
import { getViewPort, queryParse, serialize } from "../../util/index";
|
14
13
|
import { componentSignEnum } from "../../types";
|
15
|
-
|
14
|
+
import { isDebugLog } from "../../util/debug";
|
15
|
+
import { getViewPort, queryParse, serialize } from "../../util/index";
|
16
|
+
import { Logger } from "../../util/logger";
|
17
|
+
import { getLastAppVersion, getMatchAppVersion, setLastAppVersion } from "../../util/upgrade";
|
18
|
+
var getAppVersion = function getAppVersion(_extendInfo, productScene, mid) {
|
16
19
|
try {
|
17
|
-
var
|
18
|
-
|
20
|
+
var _Logger$getInstance;
|
21
|
+
var appVersion = getMatchAppVersion(_extendInfo, {
|
22
|
+
sdkVersion: sdkVersion,
|
23
|
+
productScene: productScene,
|
24
|
+
mid: mid
|
25
|
+
});
|
26
|
+
// 有sessionData加载时
|
27
|
+
(_Logger$getInstance = Logger.getInstance()) === null || _Logger$getInstance === void 0 || _Logger$getInstance.logInfo({
|
28
|
+
title: 'sdk_event_appUpgradeInfo'
|
29
|
+
}, {
|
30
|
+
appUpgradeVersion: appVersion,
|
31
|
+
appUpgraded: appVersion ? true : false,
|
32
|
+
isPreload: _extendInfo ? false : true,
|
33
|
+
extendInfo: _extendInfo,
|
34
|
+
productScene: productScene,
|
35
|
+
mid: mid
|
36
|
+
});
|
37
|
+
// 没有匹配到版本,查询上次的加载版本
|
38
|
+
if (!appVersion) {
|
39
|
+
appVersion = getLastAppVersion(productScene);
|
40
|
+
return appVersion;
|
41
|
+
}
|
42
|
+
// 不为空时代表是有sessionData,因此要保存当前版本
|
43
|
+
if (_extendInfo) {
|
44
|
+
setLastAppVersion(productScene, appVersion);
|
45
|
+
}
|
46
|
+
return appVersion;
|
19
47
|
} catch (error) {
|
20
48
|
return '';
|
21
49
|
}
|
@@ -34,13 +62,26 @@ export var getAppPath = function getAppPath() {
|
|
34
62
|
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
35
63
|
var appVersion = arguments.length > 1 ? arguments[1] : undefined;
|
36
64
|
var componentSign = arguments.length > 2 ? arguments[2] : undefined;
|
37
|
-
var
|
38
|
-
var
|
65
|
+
var productScene = arguments.length > 3 ? arguments[3] : undefined;
|
66
|
+
var productSceneVersion = arguments.length > 4 ? arguments[4] : undefined;
|
67
|
+
var extendInfo = arguments.length > 5 ? arguments[5] : undefined;
|
68
|
+
var mid = arguments.length > 6 ? arguments[6] : undefined;
|
39
69
|
var _ref = queryParse() || {},
|
40
70
|
urlTestHost = _ref.host;
|
41
|
-
var
|
71
|
+
var upgradeAppVersion = getAppVersion(extendInfo, productScene, mid);
|
72
|
+
var finalAppVersion = upgradeAppVersion || appVersion;
|
73
|
+
// 当有升级版本时,更新到全局字段
|
74
|
+
if (upgradeAppVersion) {
|
75
|
+
var _Logger$getInstance2;
|
76
|
+
(_Logger$getInstance2 = Logger.getInstance()) === null || _Logger$getInstance2 === void 0 || _Logger$getInstance2.setMedta({
|
77
|
+
webAppVersion: finalAppVersion
|
78
|
+
});
|
79
|
+
}
|
80
|
+
if (isDebugLog()) {
|
81
|
+
console.log('appUpgrade#getAppPath#finalAppVersion', finalAppVersion);
|
82
|
+
console.log('appUpgrade#getAppPath#extendInfo', extendInfo, mid);
|
83
|
+
}
|
42
84
|
var finalProductSceneVersion = getFinalProductSceneVersion(componentSign, productSceneVersion);
|
43
|
-
|
44
85
|
// only for test while testurl?host=https://xxxxx.test.html
|
45
86
|
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
|
46
87
|
return urlTestHost;
|
@@ -51,10 +92,12 @@ export var getAppDomain = function getAppDomain(domainParams) {
|
|
51
92
|
var environment = domainParams.environment,
|
52
93
|
appVersion = domainParams.appVersion,
|
53
94
|
componentSign = domainParams.componentSign,
|
95
|
+
productScene = domainParams.productScene,
|
54
96
|
productSceneVersion = domainParams.productSceneVersion,
|
55
|
-
extendInfo = domainParams.extendInfo
|
97
|
+
extendInfo = domainParams.extendInfo,
|
98
|
+
mid = domainParams.mid;
|
56
99
|
var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
|
57
|
-
var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo));
|
100
|
+
var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo, mid));
|
58
101
|
return macth && macth[0] || '';
|
59
102
|
};
|
60
103
|
export var getIframeUrl = function getIframeUrl(iframeParams) {
|
@@ -63,6 +106,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
63
106
|
analytics = _iframeParams$analyti === void 0 ? {
|
64
107
|
enabled: true
|
65
108
|
} : _iframeParams$analyti,
|
109
|
+
productScene = iframeParams.productScene,
|
66
110
|
productSceneVersion = iframeParams.productSceneVersion,
|
67
111
|
environment = iframeParams.environment,
|
68
112
|
appVersion = iframeParams.appVersion,
|
@@ -73,8 +117,15 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
73
117
|
_iframeParams$isPrelo = iframeParams.isPreload,
|
74
118
|
isPreload = _iframeParams$isPrelo === void 0 ? '' : _iframeParams$isPrelo,
|
75
119
|
_iframeParams$hostSig = iframeParams.hostSign,
|
76
|
-
hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig
|
77
|
-
|
120
|
+
hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig,
|
121
|
+
_iframeParams$mid = iframeParams.mid,
|
122
|
+
mid = _iframeParams$mid === void 0 ? '' : _iframeParams$mid;
|
123
|
+
var path = getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo || '', mid);
|
124
|
+
var appMatched = getMatchAppVersion(extendInfo, {
|
125
|
+
sdkVersion: sdkVersion,
|
126
|
+
productScene: productScene,
|
127
|
+
mid: mid
|
128
|
+
}) ? 'true' : 'false';
|
78
129
|
var initialScale = 1;
|
79
130
|
var scale = getViewPort('initial-scale') || initialScale;
|
80
131
|
var _queryParse = queryParse(),
|
@@ -91,6 +142,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
91
142
|
locale: locale,
|
92
143
|
scale: scale,
|
93
144
|
instanceId: instanceId,
|
145
|
+
appMatched: appMatched,
|
94
146
|
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
95
147
|
sdkVersion: sdkVersion,
|
96
148
|
refUrl: window.location.href,
|
@@ -106,6 +158,10 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
106
158
|
if (_displayType) urlParams.displayType = _displayType;
|
107
159
|
if (isPreload) urlParams.isPreload = isPreload;
|
108
160
|
var locationSearch = serialize(urlParams);
|
161
|
+
if (isDebugLog()) {
|
162
|
+
console.log('appUpgrade#getIframeUrl#appMatched', appMatched);
|
163
|
+
console.log('appUpgrade#getIframeUrl#url', path, locationSearch);
|
164
|
+
}
|
109
165
|
return {
|
110
166
|
path: path,
|
111
167
|
locationSearch: locationSearch
|