@alipay/ams-checkout 0.0.1710212811-dev.34 → 0.0.1710212811-dev.37

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.
@@ -1,4 +1,4 @@
1
- import { Logger } from '../../../util/logger';
1
+ import type { Logger } from '../../../util/logger';
2
2
  import { BusContext, BusMessage, BusSubscriber } from '../index';
3
3
  export declare class TrackerBusSubscriber extends BusSubscriber {
4
4
  logger: Logger;
@@ -1,14 +1,11 @@
1
- import { Logger } from "../../util/logger";
1
+ import type { Logger } from "../../util/logger";
2
2
  /**
3
- * 公用字段:
4
- * publish_v: string 发送者版本
5
- * base_v: string 基础包版本
3
+ * Bus 埋点内容定义
6
4
  */
7
5
  export declare enum BusLogEventEnum {
8
6
  /**
9
7
  * 发送消息
10
8
  * action:string
11
- * sub: bool 是否订阅
12
9
  */
13
10
  sdk_event_busPublishMessage = "sdk_event_busPublishMessage",
14
11
  /**
@@ -11,9 +11,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  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); }
13
13
  /**
14
- * 公用字段:
15
- * publish_v: string 发送者版本
16
- * base_v: string 基础包版本
14
+ * Bus 埋点内容定义
17
15
  */
18
16
  export var BusLogEventEnum = /*#__PURE__*/function (BusLogEventEnum) {
19
17
  BusLogEventEnum["sdk_event_busPublishMessage"] = "sdk_event_busPublishMessage";
@@ -6,7 +6,7 @@
6
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
7
  */
8
8
  import { ApplePaySubTypeEnum, IAppendParams, IApplePayOptionsParams } from '../../types';
9
- import { Logger } from '../../util/logger';
9
+ import type { Logger } from '../../util/logger';
10
10
  export declare enum ApplePayComponentEvent {
11
11
  sdk_event_appleAvailable = "sdk_event_appleAvailable",
12
12
  sdk_event_appleCreateComponent = "sdk_event_appleCreateComponent",
@@ -330,7 +330,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
330
330
  try {
331
331
  this._applePayService.startPay(this._parseData);
332
332
  } catch (error) {
333
- logError("appple runtime excepiton", error);
333
+ logError(eventCodeEnum.SDK_PAYMENT_ERROR, "appple runtime excepiton", error);
334
334
  }
335
335
  }
336
336
  }]);
@@ -1,4 +1,4 @@
1
- import { Logger } from "../../util/logger";
1
+ import type { Logger } from "../../util/logger";
2
2
  import { BusContext, BusMessage, BusSubscriber } from "../../core/bus";
3
3
  export declare class ApplePayInitMessage {
4
4
  private environment;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError } from './interface';
9
9
  import { ApplePaySubTypeEnum, IpaymentSessionMetaData } from '../../types';
10
- import { Logger } from '../../util/logger';
10
+ import type { Logger } from '../../util/logger';
11
11
  /**
12
12
  * Apple Pay Service
13
13
  */
@@ -1,15 +1,18 @@
1
- import { renderDisplayTypeEnum, componentSignEnum, Ianalytics } from '../../types';
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,27 @@ 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
- var getAppVersion = function getAppVersion(_extendInfo) {
14
+ import { isDebugLog } from "../../util/debug";
15
+ import { getViewPort, queryParse, serialize } from "../../util/index";
16
+ import { getLastAppVersion, getMatchAppVersion, setLastAppVersion } from "../../util/upgrade";
17
+ var getAppVersion = function getAppVersion(_extendInfo, productScene, mid) {
16
18
  try {
17
- var info = JSON.parse(_extendInfo);
18
- return info.versionMap.web[sdkVersion].targetWebVerison;
19
+ var appVersion = getMatchAppVersion(_extendInfo, {
20
+ sdkVersion: sdkVersion,
21
+ productScene: productScene,
22
+ mid: mid
23
+ });
24
+ // 没有匹配到版本,查询上次的加载版本
25
+ if (!appVersion) {
26
+ appVersion = getLastAppVersion(productScene);
27
+ return appVersion;
28
+ }
29
+ // 不为空时代表是有sessionData,因此要保存当前版本
30
+ if (_extendInfo) {
31
+ setLastAppVersion(productScene, appVersion);
32
+ }
33
+ return appVersion;
19
34
  } catch (error) {
20
35
  return '';
21
36
  }
@@ -34,13 +49,18 @@ export var getAppPath = function getAppPath() {
34
49
  var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
35
50
  var appVersion = arguments.length > 1 ? arguments[1] : undefined;
36
51
  var componentSign = arguments.length > 2 ? arguments[2] : undefined;
37
- var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
38
- var extendInfo = arguments.length > 4 ? arguments[4] : undefined;
52
+ var productScene = arguments.length > 3 ? arguments[3] : undefined;
53
+ var productSceneVersion = arguments.length > 4 ? arguments[4] : undefined;
54
+ var extendInfo = arguments.length > 5 ? arguments[5] : undefined;
55
+ var mid = arguments.length > 6 ? arguments[6] : undefined;
39
56
  var _ref = queryParse() || {},
40
57
  urlTestHost = _ref.host;
41
- var finalAppVersion = getAppVersion(extendInfo) || appVersion;
58
+ var finalAppVersion = getAppVersion(extendInfo, productScene, mid) || appVersion;
59
+ if (isDebugLog()) {
60
+ console.log('appUpgrade#getAppPath#finalAppVersion', finalAppVersion);
61
+ console.log('appUpgrade#getAppPath#extendInfo', extendInfo, mid);
62
+ }
42
63
  var finalProductSceneVersion = getFinalProductSceneVersion(componentSign, productSceneVersion);
43
-
44
64
  // only for test while testurl?host=https://xxxxx.test.html
45
65
  if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
46
66
  return urlTestHost;
@@ -51,10 +71,12 @@ export var getAppDomain = function getAppDomain(domainParams) {
51
71
  var environment = domainParams.environment,
52
72
  appVersion = domainParams.appVersion,
53
73
  componentSign = domainParams.componentSign,
74
+ productScene = domainParams.productScene,
54
75
  productSceneVersion = domainParams.productSceneVersion,
55
- extendInfo = domainParams.extendInfo;
76
+ extendInfo = domainParams.extendInfo,
77
+ mid = domainParams.mid;
56
78
  var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
57
- var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo));
79
+ var macth = reg.exec(getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo, mid));
58
80
  return macth && macth[0] || '';
59
81
  };
60
82
  export var getIframeUrl = function getIframeUrl(iframeParams) {
@@ -63,6 +85,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
63
85
  analytics = _iframeParams$analyti === void 0 ? {
64
86
  enabled: true
65
87
  } : _iframeParams$analyti,
88
+ productScene = iframeParams.productScene,
66
89
  productSceneVersion = iframeParams.productSceneVersion,
67
90
  environment = iframeParams.environment,
68
91
  appVersion = iframeParams.appVersion,
@@ -73,8 +96,15 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
73
96
  _iframeParams$isPrelo = iframeParams.isPreload,
74
97
  isPreload = _iframeParams$isPrelo === void 0 ? '' : _iframeParams$isPrelo,
75
98
  _iframeParams$hostSig = iframeParams.hostSign,
76
- hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig;
77
- var path = getAppPath(environment, appVersion, componentSign, productSceneVersion, extendInfo || '');
99
+ hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig,
100
+ _iframeParams$mid = iframeParams.mid,
101
+ mid = _iframeParams$mid === void 0 ? '' : _iframeParams$mid;
102
+ var path = getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo || '', mid);
103
+ var appUpgraded = getMatchAppVersion(extendInfo, {
104
+ sdkVersion: sdkVersion,
105
+ productScene: productScene,
106
+ mid: mid
107
+ }) ? 'true' : 'false';
78
108
  var initialScale = 1;
79
109
  var scale = getViewPort('initial-scale') || initialScale;
80
110
  var _queryParse = queryParse(),
@@ -91,6 +121,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
91
121
  locale: locale,
92
122
  scale: scale,
93
123
  instanceId: instanceId,
124
+ appUpgraded: appUpgraded,
94
125
  analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
95
126
  sdkVersion: sdkVersion,
96
127
  refUrl: window.location.href,
@@ -106,6 +137,10 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
106
137
  if (_displayType) urlParams.displayType = _displayType;
107
138
  if (isPreload) urlParams.isPreload = isPreload;
108
139
  var locationSearch = serialize(urlParams);
140
+ if (isDebugLog()) {
141
+ console.log('appUpgrade#getIframeUrl#appUpgraded', appUpgraded);
142
+ console.log('appUpgrade#getIframeUrl#url', path, locationSearch);
143
+ }
109
144
  return {
110
145
  path: path,
111
146
  locationSearch: locationSearch
@@ -54,7 +54,7 @@ var ComponentApp = /*#__PURE__*/function () {
54
54
  _defineProperty(this, "_merchantAppointParam", void 0);
55
55
  _defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
56
56
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
57
- this._appVersion = '1.10.1';
57
+ this._appVersion = '1.13.0.1';
58
58
  this._isInitComponent = false;
59
59
  this._selector = "#".concat(COMPONENT_SECTION_ID);
60
60
  this.createIframeNode = function () {
@@ -652,6 +652,7 @@ var ComponentApp = /*#__PURE__*/function () {
652
652
  analytics: {
653
653
  enabled: false
654
654
  },
655
+ productScene: componentSign,
655
656
  productSceneVersion: productSceneVersion,
656
657
  environment: this.AMSSDK.options.env.environment,
657
658
  // TODO 确定一下这个参数是干啥的
@@ -659,7 +660,8 @@ var ComponentApp = /*#__PURE__*/function () {
659
660
  extendInfo: '',
660
661
  locale: '',
661
662
  instanceId: '',
662
- isPreload: 'true'
663
+ isPreload: 'true',
664
+ mid: ''
663
665
  }),
664
666
  path = _getIframeUrl.path,
665
667
  locationSearch = _getIframeUrl.locationSearch;
@@ -689,16 +691,20 @@ var ComponentApp = /*#__PURE__*/function () {
689
691
  value: Date.now()
690
692
  });
691
693
  try {
692
- var _renderParams$payment, _renderParams$payment2;
694
+ var _renderParams$payment, _renderParams$payment2, _renderParams$payment3, _renderParams$payment4;
693
695
  var productSceneVersion = (renderParams === null || renderParams === void 0 || (_renderParams$payment = renderParams.paymentSessionMetaData) === null || _renderParams$payment === void 0 || (_renderParams$payment = _renderParams$payment.paymentSessionConfig) === null || _renderParams$payment === void 0 ? void 0 : _renderParams$payment.productSceneVersion) || '';
694
- var extendInfo = (renderParams === null || renderParams === void 0 || (_renderParams$payment2 = renderParams.paymentSessionMetaData) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.extendInfo) || '';
696
+ var productScene = (renderParams === null || renderParams === void 0 || (_renderParams$payment2 = renderParams.paymentSessionMetaData) === null || _renderParams$payment2 === void 0 || (_renderParams$payment2 = _renderParams$payment2.paymentSessionConfig) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.productScene) || '';
697
+ var extendInfo = (renderParams === null || renderParams === void 0 || (_renderParams$payment3 = renderParams.paymentSessionMetaData) === null || _renderParams$payment3 === void 0 ? void 0 : _renderParams$payment3.extendInfo) || '';
698
+ var mid = renderParams === null || renderParams === void 0 || (_renderParams$payment4 = renderParams.paymentSessionMetaData) === null || _renderParams$payment4 === void 0 ? void 0 : _renderParams$payment4.clientId;
695
699
  var environment = this.AMSSDK.options.env.environment;
696
700
  this.appDomain = getAppDomain({
697
701
  environment: environment,
698
702
  appVersion: this._appVersion,
699
703
  componentSign: this._componentSign,
704
+ productScene: productScene,
700
705
  productSceneVersion: productSceneVersion,
701
- extendInfo: extendInfo
706
+ extendInfo: extendInfo,
707
+ mid: mid
702
708
  });
703
709
  this.app = createIframe(this.AMSSDK.options.mode, this.platform);
704
710
  var hostSign = ((renderParams === null || renderParams === void 0 ? void 0 : renderParams.sessionData) || '').split('&&')[1] || '';
@@ -706,13 +712,15 @@ var ComponentApp = /*#__PURE__*/function () {
706
712
  renderDisplayType: renderParams.renderDisplayType,
707
713
  componentSign: this._componentSign,
708
714
  analytics: this.AMSSDK.options.analytics,
715
+ productScene: productScene,
709
716
  productSceneVersion: productSceneVersion,
710
717
  environment: environment,
711
718
  appVersion: this._appVersion,
712
719
  extendInfo: extendInfo,
713
720
  locale: this.AMSSDK.options.locale,
714
721
  instanceId: this.AMSSDK._instanceId,
715
- hostSign: hostSign
722
+ hostSign: hostSign,
723
+ mid: mid
716
724
  }),
717
725
  path = _getIframeUrl2.path,
718
726
  locationSearch = _getIframeUrl2.locationSearch;
@@ -1,2 +1 @@
1
- ;
2
1
  export {};
@@ -1,5 +1,5 @@
1
1
  import { RequestConfig } from '../types';
2
- import { Logger } from '../util/logger';
2
+ import type { Logger } from '../util/logger';
3
3
  /**
4
4
  *
5
5
  * @param requestData 请求参数
@@ -1,5 +1,5 @@
1
1
  import { ApplePayPaymentSessionRequest, ApplePayPaymentSessionResult, CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, RequestConfig } from '../types';
2
- import { Logger } from '../util/logger';
2
+ import type { Logger } from '../util/logger';
3
3
  export declare function queryPaymentInfo(params: CashierSdkActionQueryRequest, options: RequestConfig, logger: Logger): Promise<CashierSdkActionQueryResult>;
4
4
  export declare function antomConfig(options: RequestConfig, logger: Logger): Promise<any>;
5
5
  export declare function submitPayInfo(params: CashierSubmitPayRequest, options: RequestConfig, logger: Logger): Promise<CashierSubmitPayResult>;
@@ -0,0 +1 @@
1
+ export declare const isDebugLog: () => boolean;
@@ -0,0 +1,9 @@
1
+ import { queryParse } from ".";
2
+ export var isDebugLog = function isDebugLog() {
3
+ var _ref = queryParse() || {},
4
+ environment = _ref.environment;
5
+ if (!environment) {
6
+ return false;
7
+ }
8
+ return environment !== 'prod';
9
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getStorageString: (key: string, fallback?: string) => string;
2
+ export declare const setStorageValue: (key: string, value: string) => boolean;
@@ -0,0 +1,23 @@
1
+ export var getStorageString = function getStorageString(key) {
2
+ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3
+ try {
4
+ if (key && window) {
5
+ var storageValue = window.localStorage.getItem(key);
6
+ if (storageValue) {
7
+ return storageValue;
8
+ }
9
+ return fallback;
10
+ }
11
+ } catch (error) {
12
+ return fallback;
13
+ }
14
+ };
15
+ export var setStorageValue = function setStorageValue(key, value) {
16
+ try {
17
+ if (key && window) {
18
+ window.localStorage.setItem(key, value);
19
+ return true;
20
+ }
21
+ } catch (error) {}
22
+ return false;
23
+ };
@@ -0,0 +1,39 @@
1
+ export declare function isWebPlatform(platform?: string): boolean;
2
+ export interface UpgradeItem {
3
+ productScene?: string;
4
+ v: string;
5
+ appVersion: string;
6
+ platform?: string;
7
+ mid?: string;
8
+ greyscale?: string;
9
+ }
10
+ export interface UpgradeSdkInfo {
11
+ productScene?: string;
12
+ sdkVersion: string;
13
+ appVersion?: string;
14
+ greyscale?: number;
15
+ mid?: string;
16
+ }
17
+ export declare function findUpgradeVersion(upgradeItems: UpgradeItem[], sdkInfo: UpgradeSdkInfo): string;
18
+ export declare const getGrascaleId: (key?: string) => string;
19
+ export declare function getGrayscaleValue(seed?: string): number;
20
+ export declare function isGreyscaleMatch(item: UpgradeItem, randomGreyscale: number): boolean;
21
+ /**
22
+ * 查询匹配到的版本
23
+ * @param _extendInfo
24
+ * @param param1
25
+ * @returns
26
+ */
27
+ export declare const getMatchAppVersion: (_extendInfo: string, sdkInfo: UpgradeSdkInfo) => string;
28
+ /**
29
+ * 获取保存的加载版本
30
+ * @param productScene
31
+ * @returns
32
+ */
33
+ export declare const getLastAppVersion: (productScene: string) => string;
34
+ /**
35
+ * 保存指定场景的加载版本供下次使用
36
+ * @param productScene
37
+ * @returns
38
+ */
39
+ export declare const setLastAppVersion: (productScene: string, appVersion: string) => boolean;
@@ -0,0 +1,115 @@
1
+ import { v4 as uuid } from 'uuid';
2
+ import { getStorageString, setStorageValue } from "./storage";
3
+ import { compareVersion, isVersionInRange } from "./versionCompare";
4
+ export function isWebPlatform(platform) {
5
+ if (platform) {
6
+ return platform.toUpperCase().includes('Web'.toUpperCase()) || platform === '';
7
+ }
8
+ return true;
9
+ }
10
+ export function findUpgradeVersion(upgradeItems, sdkInfo) {
11
+ var sortedItems = upgradeItems.sort(function (a, b) {
12
+ return compareVersion(b.appVersion, a.appVersion);
13
+ });
14
+ // console.log("sortedItems",sortedItems)
15
+ var upgradeItem = sortedItems.find(function (item) {
16
+ if (isVersionInRange(sdkInfo.sdkVersion, item.v) && isWebPlatform(item.platform)) {
17
+ var _item$productScene, _sdkInfo$productScene, _item$mid, _sdkInfo$mid, _sdkInfo$greyscale;
18
+ var matchProductScene = (_item$productScene = item.productScene) !== null && _item$productScene !== void 0 && _item$productScene.trim() ? item.productScene.toUpperCase().includes(sdkInfo === null || sdkInfo === void 0 || (_sdkInfo$productScene = sdkInfo.productScene) === null || _sdkInfo$productScene === void 0 ? void 0 : _sdkInfo$productScene.toUpperCase()) : true;
19
+ var matchMid = (_item$mid = item.mid) !== null && _item$mid !== void 0 && _item$mid.trim() ? item.mid.toUpperCase().includes(sdkInfo === null || sdkInfo === void 0 || (_sdkInfo$mid = sdkInfo.mid) === null || _sdkInfo$mid === void 0 ? void 0 : _sdkInfo$mid.toUpperCase()) : true;
20
+ var matchGreyscale = isGreyscaleMatch(item, (_sdkInfo$greyscale = sdkInfo.greyscale) !== null && _sdkInfo$greyscale !== void 0 ? _sdkInfo$greyscale : getGrayscaleValue());
21
+ if (matchProductScene && matchMid && matchGreyscale) {
22
+ return item;
23
+ }
24
+ }
25
+ });
26
+ return (upgradeItem === null || upgradeItem === void 0 ? void 0 : upgradeItem.appVersion) || null;
27
+ }
28
+ export var getGrascaleId = function getGrascaleId() {
29
+ var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'AntomDefaultGrascaleId';
30
+ try {
31
+ if (key && window) {
32
+ var storageValue = getStorageString(key, '');
33
+ if (storageValue) {
34
+ return storageValue;
35
+ }
36
+ var grascaleId = uuid();
37
+ if (key && grascaleId) {
38
+ setStorageValue(key, grascaleId);
39
+ }
40
+ }
41
+ } catch (error) {
42
+ return '';
43
+ }
44
+ };
45
+ export function getGrayscaleValue() {
46
+ var seed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGrascaleId();
47
+ if (!seed) {
48
+ return 0;
49
+ }
50
+ // 取倒数2、3位
51
+ var sub = seed.substring(seed.length - 3, seed.length - 1);
52
+ // 将16进制转成10进制值
53
+ var decimal = parseInt(sub, 16);
54
+ var finalValue = Math.floor(decimal * 100 / 255);
55
+ return finalValue;
56
+ }
57
+ export function isGreyscaleMatch(item, randomGreyscale) {
58
+ if (!(item !== null && item !== void 0 && item.greyscale)) {
59
+ return true;
60
+ }
61
+ try {
62
+ var greyscale = parseInt(item === null || item === void 0 ? void 0 : item.greyscale);
63
+ if (greyscale === 0) {
64
+ return false;
65
+ }
66
+ return greyscale >= randomGreyscale;
67
+ } catch (error) {
68
+ return false;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * 查询匹配到的版本
74
+ * @param _extendInfo
75
+ * @param param1
76
+ * @returns
77
+ */
78
+ export var getMatchAppVersion = function getMatchAppVersion(_extendInfo, sdkInfo) {
79
+ try {
80
+ var _info$sdkUpdateInfo;
81
+ var info = JSON.parse(_extendInfo);
82
+ var forceUpgradeVersions = info === null || info === void 0 || (_info$sdkUpdateInfo = info.sdkUpdateInfo) === null || _info$sdkUpdateInfo === void 0 ? void 0 : _info$sdkUpdateInfo.forceUpgradeVersions;
83
+ var appVersion = findUpgradeVersion(forceUpgradeVersions, sdkInfo);
84
+ return appVersion;
85
+ } catch (error) {
86
+ return '';
87
+ }
88
+ };
89
+
90
+ /**
91
+ * 获取保存的加载版本
92
+ * @param productScene
93
+ * @returns
94
+ */
95
+ export var getLastAppVersion = function getLastAppVersion(productScene) {
96
+ try {
97
+ var key = "Antom_".concat(productScene, "_LastAppVersion");
98
+ return getStorageString(key, '');
99
+ } catch (error) {
100
+ return '';
101
+ }
102
+ };
103
+ /**
104
+ * 保存指定场景的加载版本供下次使用
105
+ * @param productScene
106
+ * @returns
107
+ */
108
+ export var setLastAppVersion = function setLastAppVersion(productScene, appVersion) {
109
+ try {
110
+ var key = "Antom_".concat(productScene, "_LastAppVersion");
111
+ return setStorageValue(key, appVersion);
112
+ } catch (error) {
113
+ return false;
114
+ }
115
+ };
@@ -4,3 +4,4 @@
4
4
  * @param v2
5
5
  */
6
6
  export declare function compareVersion(v1: string, v2: string): 1 | 0 | -1;
7
+ export declare function isVersionInRange(version: string, range: string): boolean;
@@ -42,4 +42,20 @@ export function compareVersion(v1, v2) {
42
42
  } else {
43
43
  return 1;
44
44
  }
45
+ }
46
+ export function isVersionInRange(version, range) {
47
+ if (!range) {
48
+ // 未指定版本限制
49
+ return true;
50
+ }
51
+ if (range.includes(',')) {
52
+ return range.split(',').includes(version);
53
+ }
54
+ if (!range.includes('|')) {
55
+ return version === range;
56
+ }
57
+ var minVersion = range.split('|')[0];
58
+ var maxVersion = range.split('|')[1] || '999.9.9';
59
+ var matchVersion = compareVersion(version, minVersion) >= 0 && compareVersion(maxVersion, version) >= 0;
60
+ return matchVersion;
45
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1710212811-dev.34",
3
+ "version": "0.0.1710212811-dev.37",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",