@alipay/ams-checkout 0.0.1713146800-dev.0 → 0.0.1713838058-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.
Files changed (40) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/request.js +3 -3
  3. package/esm/core/bus/index.d.ts +1 -1
  4. package/esm/core/bus/interface.d.ts +5 -1
  5. package/esm/core/bus/interface.js +6 -1
  6. package/esm/core/component/index.d.ts +1 -0
  7. package/esm/core/component/index.js +14 -6
  8. package/esm/core/instance/index.d.ts +8 -1
  9. package/esm/core/instance/index.js +22 -14
  10. package/esm/plugin/applepay/component.d.ts +1 -1
  11. package/esm/plugin/applepay/component.js +5 -5
  12. package/esm/plugin/applepay/index.d.ts +1 -1
  13. package/esm/plugin/applepay/index.js +6 -6
  14. package/esm/plugin/component/cashierApp.d.ts +6 -2
  15. package/esm/plugin/component/cashierApp.js +68 -12
  16. package/esm/plugin/component/component.popup.style.js +1 -1
  17. package/esm/plugin/component/index.d.ts +1 -2
  18. package/esm/plugin/component/index.js +153 -89
  19. package/esm/plugin/const.js +18 -4
  20. package/esm/plugin/paypal/index.d.ts +20 -0
  21. package/esm/plugin/paypal/index.js +389 -0
  22. package/esm/plugin/type.d.ts +2 -2
  23. package/esm/plugin/utils.d.ts +6 -0
  24. package/esm/plugin/utils.js +21 -0
  25. package/esm/request/index.js +8 -14
  26. package/esm/types/index.d.ts +58 -3
  27. package/esm/types/index.js +18 -0
  28. package/esm/util/debug.d.ts +1 -0
  29. package/esm/util/debug.js +9 -0
  30. package/esm/util/index.d.ts +2 -1
  31. package/esm/util/index.js +4 -2
  32. package/esm/util/logger.d.ts +8 -0
  33. package/esm/util/logger.js +34 -3
  34. package/esm/util/storage.d.ts +2 -0
  35. package/esm/util/storage.js +23 -0
  36. package/esm/util/upgrade.d.ts +39 -0
  37. package/esm/util/upgrade.js +115 -0
  38. package/esm/util/versionCompare.d.ts +10 -1
  39. package/esm/util/versionCompare.js +97 -0
  40. package/package.json +1 -1
@@ -41,6 +41,15 @@ export var paymentMethodCategoryTypeEnum = /*#__PURE__*/function (paymentMethodC
41
41
  paymentMethodCategoryTypeEnum["APM"] = "APM";
42
42
  return paymentMethodCategoryTypeEnum;
43
43
  }({});
44
+ export var payPalConfigurationIntentEnum = /*#__PURE__*/function (payPalConfigurationIntentEnum) {
45
+ payPalConfigurationIntentEnum["intent"] = "intent";
46
+ payPalConfigurationIntentEnum["capture"] = "capture";
47
+ return payPalConfigurationIntentEnum;
48
+ }({});
49
+ export var PaymentAmountEnum = /*#__PURE__*/function (PaymentAmountEnum) {
50
+ PaymentAmountEnum["USD"] = "USD";
51
+ return PaymentAmountEnum;
52
+ }({});
44
53
  export var localeEnum = /*#__PURE__*/function (localeEnum) {
45
54
  localeEnum["en-US"] = "en-US";
46
55
  return localeEnum;
@@ -158,6 +167,9 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
158
167
  eventCodeEnum["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
159
168
  eventCodeEnum["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
160
169
  eventCodeEnum["SDK_PAYMENT_PROCESSING"] = "SDK_PAYMENT_PROCESSING";
170
+ eventCodeEnum["SDK_PAYMENT_WARN"] = "SDK_PAYMENT_WARN";
171
+ eventCodeEnum["SDK_PAYMENT_SHIPPINGCHANGE"] = "SDK_PAYMENT_SHIPPINGCHANGE";
172
+ eventCodeEnum["SDK_PAYMENT_APPROVE"] = "SDK_PAYMENT_APPROVE";
161
173
  return eventCodeEnum;
162
174
  }({});
163
175
  export var RedirectType = /*#__PURE__*/function (RedirectType) {
@@ -167,6 +179,12 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
167
179
  RedirectType["Unknown"] = "Unknown";
168
180
  return RedirectType;
169
181
  }({});
182
+ export var PaypalMethodEnum = /*#__PURE__*/function (PaypalMethodEnum) {
183
+ PaypalMethodEnum["PAYPAL_CHECKOUT"] = "PAYPAL_CHECKOUT";
184
+ PaypalMethodEnum["PAYPAL_VAULT"] = "PAYPAL_VAULT";
185
+ PaypalMethodEnum["PAYPAL_PAYLATER"] = "PAYPAL_PAYLATER";
186
+ return PaypalMethodEnum;
187
+ }({});
170
188
  export var ProductSceneVersion = /*#__PURE__*/function (ProductSceneVersion) {
171
189
  ProductSceneVersion["V1"] = "1.0";
172
190
  ProductSceneVersion["V2"] = "2.0";
@@ -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
+ };
@@ -37,5 +37,6 @@ declare const addSetFontSizeEvent: () => void;
37
37
  */
38
38
  declare const getOrSetStorageId: (key: string, value?: string) => string;
39
39
  declare const checkTimeElapsed: () => boolean;
40
+ declare const isFunction: (func: any) => boolean;
40
41
  declare function parseBase64ToString(base64: string): string;
41
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, };
42
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, };
package/esm/util/index.js CHANGED
@@ -246,7 +246,9 @@ var checkTimeElapsed = function checkTimeElapsed() {
246
246
  localStorage.setItem(key, currentTime.toString());
247
247
  return true;
248
248
  };
249
-
249
+ var isFunction = function isFunction(func) {
250
+ return typeof func === 'function';
251
+ };
250
252
  // https://developer.mozilla.org/en-US/docs/Glossary/Base64
251
253
  function parseBase64ToString(base64) {
252
254
  try {
@@ -259,4 +261,4 @@ function parseBase64ToString(base64) {
259
261
  return null;
260
262
  }
261
263
  }
262
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString };
264
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString };
@@ -12,6 +12,7 @@ type Extra = Record<string, any>;
12
12
  export interface LogMetaData {
13
13
  platform?: string;
14
14
  sdkVersion?: string;
15
+ webAppVersion?: string;
15
16
  fistLogTime?: number;
16
17
  fsDuration?: number;
17
18
  instanceId?: string;
@@ -23,6 +24,7 @@ export interface LogMetaData {
23
24
  paymentMethodType?: string;
24
25
  paymentMethodCategoryType?: string;
25
26
  requestSeq?: string;
27
+ trackId?: string;
26
28
  }
27
29
  interface Config {
28
30
  scriptUrl: string;
@@ -41,7 +43,11 @@ export declare class Logger {
41
43
  private debug;
42
44
  private componentStartTime;
43
45
  private isLoaded;
46
+ private static instance;
47
+ private trackId;
44
48
  constructor(config: Config, debug: boolean);
49
+ static setInstance(instance: Logger): Logger;
50
+ static getInstance(): Logger;
45
51
  setMedta(mdata: LogMetaData): void;
46
52
  logError(error: LogPayload, extra?: Extra): Logger;
47
53
  logInfo(info: LogPayload, extra?: Extra): Logger;
@@ -51,6 +57,8 @@ export declare class Logger {
51
57
  initTracker(): void;
52
58
  send(): void;
53
59
  setComponentStartTime(val: number): void;
60
+ setTrackId(trackId: string): void;
61
+ getComponentStartTime(): number;
54
62
  }
55
63
  export declare const LogConfig: Config;
56
64
  export {};
@@ -15,6 +15,7 @@ export var Logger = /*#__PURE__*/function () {
15
15
  _defineProperty(this, "debug", void 0);
16
16
  _defineProperty(this, "componentStartTime", void 0);
17
17
  _defineProperty(this, "isLoaded", void 0);
18
+ _defineProperty(this, "trackId", void 0);
18
19
  this.logs = [];
19
20
  this.config = config;
20
21
  this.debug = debug;
@@ -99,19 +100,28 @@ export var Logger = /*#__PURE__*/function () {
99
100
  try {
100
101
  var log = logs.pop();
101
102
  if (log.type === 'error') {
103
+ var _log$logPayload;
102
104
  logError(log.logPayload, _objectSpread({
103
105
  fsDuration: fsDuration,
104
- timeStamp: now
106
+ timeStamp: now,
107
+ trackId: this.trackId,
108
+ title: (_log$logPayload = log.logPayload) === null || _log$logPayload === void 0 ? void 0 : _log$logPayload.title
105
109
  }, log === null || log === void 0 ? void 0 : log.extra));
106
110
  } else if (log.type === 'info') {
111
+ var _log$logPayload2;
107
112
  logInfo(log.logPayload, _objectSpread({
108
113
  fsDuration: fsDuration,
109
- timeStamp: now
114
+ timeStamp: now,
115
+ trackId: this.trackId,
116
+ title: (_log$logPayload2 = log.logPayload) === null || _log$logPayload2 === void 0 ? void 0 : _log$logPayload2.title
110
117
  }, log === null || log === void 0 ? void 0 : log.extra));
111
118
  } else if (log.type === 'rpc') {
119
+ var _log$logPayload3;
112
120
  reportRPC(log.logPayload, _objectSpread({
113
121
  fsDuration: fsDuration,
114
- timeStamp: now
122
+ timeStamp: now,
123
+ trackId: this.trackId,
124
+ title: (_log$logPayload3 = log.logPayload) === null || _log$logPayload3 === void 0 ? void 0 : _log$logPayload3.title
115
125
  }, log === null || log === void 0 ? void 0 : log.extra));
116
126
  }
117
127
  } catch (error) {
@@ -166,9 +176,30 @@ export var Logger = /*#__PURE__*/function () {
166
176
  value: function setComponentStartTime(val) {
167
177
  this.componentStartTime = val;
168
178
  }
179
+ }, {
180
+ key: "setTrackId",
181
+ value: function setTrackId(trackId) {
182
+ this.trackId = trackId;
183
+ }
184
+ }, {
185
+ key: "getComponentStartTime",
186
+ value: function getComponentStartTime() {
187
+ return this.componentStartTime;
188
+ }
189
+ }], [{
190
+ key: "setInstance",
191
+ value: function setInstance(instance) {
192
+ return this.instance = instance;
193
+ }
194
+ }, {
195
+ key: "getInstance",
196
+ value: function getInstance() {
197
+ return this.instance;
198
+ }
169
199
  }]);
170
200
  return Logger;
171
201
  }();
202
+ _defineProperty(Logger, "instance", void 0);
172
203
  export var LogConfig = {
173
204
  scriptUrl: 'https://gw.alipayobjects.com/render/p/yuyan_npm/@alipay_intl-tracker/1.6.0/dist/common.min.js',
174
205
  spmConfig: {},
@@ -0,0 +1,2 @@
1
+ export declare const getStorageString: (key: string, fallback?: string) => string;
2
+ export declare const setStorageString: (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 setStorageString = function setStorageString(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, setStorageString } from "./storage";
3
+ import { compareVersion, isVersionInStringRange } 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 (isVersionInStringRange(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
+ setStorageString(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$sdkUpgradeInfo;
81
+ var info = JSON.parse(_extendInfo);
82
+ var versions = info === null || info === void 0 || (_info$sdkUpgradeInfo = info.sdkUpgradeInfo) === null || _info$sdkUpgradeInfo === void 0 ? void 0 : _info$sdkUpgradeInfo.versions;
83
+ var appVersion = findUpgradeVersion(versions, 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 setStorageString(key, appVersion);
112
+ } catch (error) {
113
+ return false;
114
+ }
115
+ };
@@ -3,4 +3,13 @@
3
3
  * @param v1
4
4
  * @param v2
5
5
  */
6
- export declare function compareVersion(v1: string, v2: string): 1 | 0 | -1;
6
+ export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
7
+ /**
8
+ * 判断version版本是否在range参数版本的范围内
9
+ * @param version
10
+ * @param range
11
+ * @returns
12
+ */
13
+ export declare function isVersionInStringRange(version: string, range: string): boolean;
14
+ export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
15
+ export declare function matchVersion(config: any, currentVersion: any): boolean;
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /**
2
8
  * 返回值0标识一样大,1表示v1大,-1表示v2大
3
9
  * @param v1
@@ -42,4 +48,95 @@ export function compareVersion(v1, v2) {
42
48
  } else {
43
49
  return 1;
44
50
  }
51
+ }
52
+ /**
53
+ * 判断version版本是否在range参数版本的范围内
54
+ * @param version
55
+ * @param range
56
+ * @returns
57
+ */
58
+ export function isVersionInStringRange(version, range) {
59
+ if (!range) {
60
+ // 未指定版本限制
61
+ return true;
62
+ }
63
+ if (range.includes(',')) {
64
+ return range.split(',').includes(version);
65
+ }
66
+ if (!range.includes('|')) {
67
+ return version === range;
68
+ }
69
+ var minVersion = range.split('|')[0];
70
+ var maxVersion = range.split('|')[1] || '999999.9.9';
71
+ var matchVersion = compareVersion(version, minVersion) >= 0 && compareVersion(maxVersion, version) >= 0;
72
+ return matchVersion;
73
+ }
74
+ export function isVersionInRange(currentVersion, minVersion, maxVersion) {
75
+ function splitVersion(version) {
76
+ return version.split('.').map(function (num) {
77
+ return parseInt(num, 10);
78
+ });
79
+ }
80
+ function compareVersions(v1, v2) {
81
+ for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
82
+ var num1 = v1[i] === undefined ? 0 : v1[i];
83
+ var num2 = v2[i] === undefined ? 0 : v2[i];
84
+ if (num1 > num2) return 1;
85
+ if (num1 < num2) return -1;
86
+ }
87
+ return 0;
88
+ }
89
+ var current = splitVersion(currentVersion);
90
+ var min = minVersion ? splitVersion(minVersion) : null;
91
+ var max = maxVersion ? splitVersion(maxVersion) : null;
92
+ if (min && compareVersions(current, min) < 0) {
93
+ // 当前版本小于最小允许版本
94
+ return false;
95
+ }
96
+ if (max && compareVersions(current, max) > 0) {
97
+ // 当前版本大于最大允许版本
98
+ return false;
99
+ }
100
+ // 当前版本在允许的版本范围内
101
+ return true;
102
+ }
103
+ export function matchVersion(config, currentVersion) {
104
+ var value = config.value,
105
+ version = config.version,
106
+ platform = config.platform;
107
+ var CURRENT_PLATFORM = 'WEB';
108
+ var isMatchVersion = false;
109
+ var isMatchPlatform = false;
110
+
111
+ // 平台判断
112
+ if (platform) {
113
+ var platformList = platform.split('|').map(function (platform) {
114
+ return platform.toLocaleUpperCase();
115
+ });
116
+ isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
117
+ } else {
118
+ // 没有表示平台全匹配
119
+ isMatchPlatform = true;
120
+ }
121
+ // 版本判断
122
+ if (!version) {
123
+ // 为空全匹配
124
+ isMatchVersion = true;
125
+ } else if (version.indexOf('|') !== -1) {
126
+ // | 范围匹配
127
+ var _version$split = version.split('|'),
128
+ _version$split2 = _slicedToArray(_version$split, 2),
129
+ _version$split2$ = _version$split2[0],
130
+ minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
131
+ _version$split2$2 = _version$split2[1],
132
+ maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
133
+ isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
134
+ } else if (version.indexOf(',') !== -1) {
135
+ // , 枚举匹配
136
+ var versionList = version.split(',');
137
+ isMatchVersion = versionList.includes(currentVersion);
138
+ } else {
139
+ isMatchVersion = version === currentVersion;
140
+ }
141
+ return value && isMatchPlatform && isMatchVersion;
45
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1713146800-dev.0",
3
+ "version": "0.0.1713838058-dev.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",