@alipay/ams-checkout 0.0.1710840616-dev.0 → 0.0.1711691167-dev.3
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/request.js +3 -3
- package/esm/core/bus/ability/callback.d.ts +9 -0
- package/esm/core/bus/ability/callback.js +55 -0
- package/esm/core/bus/ability/security.d.ts +10 -0
- package/esm/core/bus/ability/security.js +104 -0
- package/esm/core/bus/ability/tracker.d.ts +9 -0
- package/esm/core/bus/ability/tracker.js +77 -0
- package/esm/core/bus/index.d.ts +125 -0
- package/esm/core/bus/index.js +366 -0
- package/esm/core/bus/interface.d.ts +36 -0
- package/esm/core/bus/interface.js +40 -0
- package/esm/core/component/index.d.ts +15 -1
- package/esm/core/component/index.js +189 -26
- package/esm/core/instance/index.d.ts +12 -1
- package/esm/core/instance/index.js +55 -12
- package/esm/index.d.ts +0 -3
- package/esm/index.js +8 -18
- package/esm/{core/applepay/index.d.ts → plugin/applepay/component.d.ts} +27 -8
- package/esm/{core/applepay/index.js → plugin/applepay/component.js} +150 -180
- package/esm/plugin/applepay/index.d.ts +17 -0
- package/esm/plugin/applepay/index.js +117 -0
- package/esm/{common → plugin}/applepay/interface.d.ts +62 -3
- package/esm/plugin/applepay/interface.js +69 -0
- package/esm/{common/applepay/index.d.ts → plugin/applepay/service.d.ts} +13 -7
- package/esm/{common/applepay/index.js → plugin/applepay/service.js} +159 -41
- package/esm/plugin/component/index.d.ts +4 -3
- package/esm/plugin/component/index.js +98 -108
- package/esm/plugin/const.d.ts +2 -0
- package/esm/plugin/const.js +33 -0
- package/esm/plugin/paypal/index.d.ts +20 -0
- package/esm/plugin/paypal/index.js +353 -0
- package/esm/plugin/type.d.ts +33 -0
- package/esm/plugin/utils.d.ts +6 -0
- package/esm/plugin/utils.js +21 -0
- package/esm/request/index.d.ts +1 -1
- package/esm/request/index.js +14 -8
- package/esm/service/index.d.ts +1 -1
- package/esm/types/index.d.ts +108 -11
- package/esm/types/index.js +26 -1
- package/esm/util/index.d.ts +2 -1
- package/esm/util/index.js +4 -2
- package/esm/util/logger.d.ts +4 -0
- package/esm/util/logger.js +23 -3
- package/esm/util/versionCompare.d.ts +1 -3
- package/esm/util/versionCompare.js +0 -75
- package/package.json +1 -1
- /package/esm/{common/applepay/interface.js → plugin/type.js} +0 -0
package/esm/types/index.d.ts
CHANGED
@@ -81,6 +81,19 @@ export interface IappendIframeNodesParams extends IcreateComponent {
|
|
81
81
|
paymentSessionMetaData: IpaymentSessionMetaData;
|
82
82
|
renderDisplayType: renderDisplayTypeEnum;
|
83
83
|
selector?: Iselector;
|
84
|
+
paypalConfiguration?: IPaypalConfiguration;
|
85
|
+
}
|
86
|
+
export interface IPaypalConfiguration {
|
87
|
+
style?: Object;
|
88
|
+
blockPayPalCreditButton?: boolean;
|
89
|
+
blockPayPalPayLaterButton?: boolean;
|
90
|
+
displayPayPalPayLaterButtonOnly?: boolean;
|
91
|
+
enableMessages?: boolean;
|
92
|
+
intent?: payPalConfigurationIntentEnum;
|
93
|
+
}
|
94
|
+
export declare enum payPalConfigurationIntentEnum {
|
95
|
+
'intent' = "intent",
|
96
|
+
'capture' = "capture"
|
84
97
|
}
|
85
98
|
export interface IMerchantAppointParam {
|
86
99
|
storedCard?: IStoredCard;
|
@@ -133,23 +146,19 @@ export interface IpaymentSessionMetaData {
|
|
133
146
|
action?: {
|
134
147
|
autoDebitWithToken: boolean;
|
135
148
|
skipSdkQuery: boolean;
|
136
|
-
skipSdkQueryForm?: {
|
137
|
-
value: boolean;
|
138
|
-
version: string;
|
139
|
-
platform: string;
|
140
|
-
};
|
141
149
|
};
|
142
150
|
paymentSessionFactor?: {
|
143
|
-
|
151
|
+
extendInfo?: {
|
144
152
|
merchantCapabilities?: string[];
|
145
153
|
supportedNetworks?: string[];
|
146
154
|
};
|
147
155
|
merchantInfo?: {
|
148
156
|
registeredCountry?: string;
|
149
157
|
partnerId?: string;
|
158
|
+
merchantName?: string;
|
150
159
|
};
|
151
160
|
order?: {
|
152
|
-
orderDescription
|
161
|
+
orderDescription: string;
|
153
162
|
};
|
154
163
|
paymentAmount?: {
|
155
164
|
value?: string;
|
@@ -161,8 +170,72 @@ export interface IpaymentSessionMetaData {
|
|
161
170
|
paymentMethodViewMetaData?: any;
|
162
171
|
paymentRequestId?: string;
|
163
172
|
supportedLanguages?: any;
|
173
|
+
/**
|
174
|
+
* 当前为苹果分期场景的信息
|
175
|
+
*/
|
176
|
+
recurringInfo?: {
|
177
|
+
/**
|
178
|
+
* 代扣协议开始日期 不传为当前系统时间
|
179
|
+
*/
|
180
|
+
startDate?: number;
|
181
|
+
/**
|
182
|
+
* 代扣协议结束日期 不传不限制结束时间
|
183
|
+
*/
|
184
|
+
endDate?: number;
|
185
|
+
/**
|
186
|
+
* 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
|
187
|
+
*/
|
188
|
+
intervalUnit?: string;
|
189
|
+
/**
|
190
|
+
* 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
|
191
|
+
*/
|
192
|
+
intervalCount?: number;
|
193
|
+
/**
|
194
|
+
* 分期标题信息
|
195
|
+
*/
|
196
|
+
title?: string;
|
197
|
+
/**
|
198
|
+
* 分期管理页面
|
199
|
+
*/
|
200
|
+
managementURL?: string;
|
201
|
+
/**
|
202
|
+
* 苹果通知ipay MAPN信息变更的地址
|
203
|
+
*/
|
204
|
+
tokenNotificationURL?: string;
|
205
|
+
/**
|
206
|
+
* 分期协议描述
|
207
|
+
*/
|
208
|
+
agreementDescription?: string;
|
209
|
+
};
|
164
210
|
};
|
165
211
|
}
|
212
|
+
export interface IPaymentSessionFactor {
|
213
|
+
merchantInfo?: IMerchantInfo;
|
214
|
+
paymentMethodInfo: IPaymentMethodInfo;
|
215
|
+
}
|
216
|
+
export interface IPaymentMethodInfo {
|
217
|
+
paymentAmount?: IPaymentAmount;
|
218
|
+
paymentMethodMetaData?: IPaymentMethodMetaData;
|
219
|
+
paymentMethodType?: PaypalMethodEnum;
|
220
|
+
paypal?: IPaypalConfig;
|
221
|
+
}
|
222
|
+
export type IPaypalConfig = {
|
223
|
+
accessToken: string;
|
224
|
+
};
|
225
|
+
export interface IPaymentMethodMetaData {
|
226
|
+
bindPaymentMethod?: string;
|
227
|
+
boundPaymentMethod?: string;
|
228
|
+
}
|
229
|
+
export interface IMerchantInfo {
|
230
|
+
channelMerchantAccountId?: string;
|
231
|
+
}
|
232
|
+
export interface IPaymentAmount {
|
233
|
+
value?: string;
|
234
|
+
currency?: PaymentAmountEnum;
|
235
|
+
}
|
236
|
+
export declare enum PaymentAmountEnum {
|
237
|
+
USD = "USD"
|
238
|
+
}
|
166
239
|
export declare enum localeEnum {
|
167
240
|
'en-US' = "en-US"
|
168
241
|
}
|
@@ -206,8 +279,8 @@ export declare enum platformEnum {
|
|
206
279
|
desktop = "desktop",
|
207
280
|
mobile = "mobile"
|
208
281
|
}
|
209
|
-
type EventCallbackResult = {
|
210
|
-
result
|
282
|
+
export type EventCallbackResult = {
|
283
|
+
result?: {
|
211
284
|
resultCode: string;
|
212
285
|
resultStatus: string;
|
213
286
|
resultMessage: string;
|
@@ -415,9 +488,17 @@ export declare enum eventCodeEnum {
|
|
415
488
|
SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
|
416
489
|
SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
|
417
490
|
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS",
|
418
|
-
|
491
|
+
SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
|
419
492
|
SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
|
420
|
-
|
493
|
+
SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
|
494
|
+
SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
|
495
|
+
/**
|
496
|
+
* 当前为Apple Pay发起了Pay请求,但是用户关闭了页面
|
497
|
+
*/
|
498
|
+
SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING",
|
499
|
+
SDK_PAYMENT_WARN = "SDK_PAYMENT_WARN",
|
500
|
+
SDK_PAYMENT_SHIPPINGCHANGE = "SDK_PAYMENT_SHIPPINGCHANGE",
|
501
|
+
SDK_PAYMENT_APPROVE = "SDK_PAYMENT_APPROVE"
|
421
502
|
}
|
422
503
|
export declare enum RedirectType {
|
423
504
|
ApplinkUrl = "ApplinkUrl",
|
@@ -438,4 +519,20 @@ export interface CallbackEventInfo {
|
|
438
519
|
export interface MultipleCallbackEvents {
|
439
520
|
[key: string]: CallbackEventInfo;
|
440
521
|
}
|
522
|
+
export declare enum PaypalMethodEnum {
|
523
|
+
PAYPAL_CHECKOUT = "PAYPAL_CHECKOUT",
|
524
|
+
PAYPAL_VAULT = "PAYPAL_VAULT",
|
525
|
+
PAYPAL_PAYLATER = "PAYPAL_PAYLATER"
|
526
|
+
}
|
527
|
+
export type PaymentMethodTypeEnum = 'ApplePay';
|
528
|
+
export type ApplePaySubTypeEnum = 'ApplePayRecurringPayment';
|
529
|
+
export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
|
530
|
+
export declare enum ProductSceneVersion {
|
531
|
+
V1 = "1.0",
|
532
|
+
V2 = "2.0"
|
533
|
+
}
|
534
|
+
export type IAppendParams = {
|
535
|
+
componentSign: componentSignEnum;
|
536
|
+
iframeNodesParams: IappendIframeNodesParams;
|
537
|
+
};
|
441
538
|
export {};
|
package/esm/types/index.js
CHANGED
@@ -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;
|
@@ -153,9 +162,14 @@ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
|
|
153
162
|
eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
|
154
163
|
eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
|
155
164
|
eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
|
156
|
-
eventCodeEnum["
|
165
|
+
eventCodeEnum["SDK_PAYMENT_SUCCESSFUL"] = "SDK_PAYMENT_SUCCESSFUL";
|
157
166
|
eventCodeEnum["SDK_PAYMENT_FAIL"] = "SDK_PAYMENT_FAIL";
|
167
|
+
eventCodeEnum["SDK_PAYMENT_ERROR"] = "SDK_PAYMENT_ERROR";
|
158
168
|
eventCodeEnum["SDK_PAYMENT_CANCEL"] = "SDK_PAYMENT_CANCEL";
|
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";
|
159
173
|
return eventCodeEnum;
|
160
174
|
}({});
|
161
175
|
export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
@@ -164,4 +178,15 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
|
164
178
|
RedirectType["NormalUrl"] = "NormalUrl";
|
165
179
|
RedirectType["Unknown"] = "Unknown";
|
166
180
|
return RedirectType;
|
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
|
+
}({});
|
188
|
+
export var ProductSceneVersion = /*#__PURE__*/function (ProductSceneVersion) {
|
189
|
+
ProductSceneVersion["V1"] = "1.0";
|
190
|
+
ProductSceneVersion["V2"] = "2.0";
|
191
|
+
return ProductSceneVersion;
|
167
192
|
}({});
|
package/esm/util/index.d.ts
CHANGED
@@ -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 };
|
package/esm/util/logger.d.ts
CHANGED
@@ -23,6 +23,7 @@ export interface LogMetaData {
|
|
23
23
|
paymentMethodType?: string;
|
24
24
|
paymentMethodCategoryType?: string;
|
25
25
|
requestSeq?: string;
|
26
|
+
trackId?: string;
|
26
27
|
}
|
27
28
|
interface Config {
|
28
29
|
scriptUrl: string;
|
@@ -41,6 +42,7 @@ export declare class Logger {
|
|
41
42
|
private debug;
|
42
43
|
private componentStartTime;
|
43
44
|
private isLoaded;
|
45
|
+
private trackId;
|
44
46
|
constructor(config: Config, debug: boolean);
|
45
47
|
setMedta(mdata: LogMetaData): void;
|
46
48
|
logError(error: LogPayload, extra?: Extra): Logger;
|
@@ -51,6 +53,8 @@ export declare class Logger {
|
|
51
53
|
initTracker(): void;
|
52
54
|
send(): void;
|
53
55
|
setComponentStartTime(val: number): void;
|
56
|
+
setTrackId(trackId: string): void;
|
57
|
+
getComponentStartTime(): number;
|
54
58
|
}
|
55
59
|
export declare const LogConfig: Config;
|
56
60
|
export {};
|
package/esm/util/logger.js
CHANGED
@@ -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,6 +176,16 @@ 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
|
+
}
|
169
189
|
}]);
|
170
190
|
return Logger;
|
171
191
|
}();
|
@@ -3,6 +3,4 @@
|
|
3
3
|
* @param v1
|
4
4
|
* @param v2
|
5
5
|
*/
|
6
|
-
export declare function compareVersion(v1: string, v2: string):
|
7
|
-
export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
|
8
|
-
export declare function matchVersion(config: any, currentVersion: any): boolean;
|
6
|
+
export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
|
@@ -1,9 +1,3 @@
|
|
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; }
|
7
1
|
/**
|
8
2
|
* 返回值0标识一样大,1表示v1大,-1表示v2大
|
9
3
|
* @param v1
|
@@ -48,73 +42,4 @@ export function compareVersion(v1, v2) {
|
|
48
42
|
} else {
|
49
43
|
return 1;
|
50
44
|
}
|
51
|
-
}
|
52
|
-
export function isVersionInRange(currentVersion, minVersion, maxVersion) {
|
53
|
-
function splitVersion(version) {
|
54
|
-
return version.split('.').map(function (num) {
|
55
|
-
return parseInt(num, 10);
|
56
|
-
});
|
57
|
-
}
|
58
|
-
function compareVersions(v1, v2) {
|
59
|
-
for (var i = 0; i < Math.max(v1.length, v2.length); i++) {
|
60
|
-
var num1 = v1[i] === undefined ? 0 : v1[i];
|
61
|
-
var num2 = v2[i] === undefined ? 0 : v2[i];
|
62
|
-
if (num1 > num2) return 1;
|
63
|
-
if (num1 < num2) return -1;
|
64
|
-
}
|
65
|
-
return 0;
|
66
|
-
}
|
67
|
-
var current = splitVersion(currentVersion);
|
68
|
-
var min = minVersion ? splitVersion(minVersion) : null;
|
69
|
-
var max = maxVersion ? splitVersion(maxVersion) : null;
|
70
|
-
if (min && compareVersions(current, min) < 0) {
|
71
|
-
// 当前版本小于最小允许版本
|
72
|
-
return false;
|
73
|
-
}
|
74
|
-
if (max && compareVersions(current, max) > 0) {
|
75
|
-
// 当前版本大于最大允许版本
|
76
|
-
return false;
|
77
|
-
}
|
78
|
-
// 当前版本在允许的版本范围内
|
79
|
-
return true;
|
80
|
-
}
|
81
|
-
export function matchVersion(config, currentVersion) {
|
82
|
-
var value = config.value,
|
83
|
-
version = config.version,
|
84
|
-
platform = config.platform;
|
85
|
-
var CURRENT_PLATFORM = 'WEB';
|
86
|
-
var isMatchVersion = false;
|
87
|
-
var isMatchPlatform = false;
|
88
|
-
|
89
|
-
// 平台判断
|
90
|
-
if (platform) {
|
91
|
-
var platformList = platform.split('|').map(function (platform) {
|
92
|
-
return platform.toLocaleUpperCase();
|
93
|
-
});
|
94
|
-
isMatchPlatform = platformList.includes(CURRENT_PLATFORM);
|
95
|
-
} else {
|
96
|
-
// 没有表示平台全匹配
|
97
|
-
isMatchPlatform = true;
|
98
|
-
}
|
99
|
-
// 版本判断
|
100
|
-
if (!version) {
|
101
|
-
// 为空全匹配
|
102
|
-
isMatchVersion = true;
|
103
|
-
} else if (version.indexOf('|') !== -1) {
|
104
|
-
// | 范围匹配
|
105
|
-
var _version$split = version.split('|'),
|
106
|
-
_version$split2 = _slicedToArray(_version$split, 2),
|
107
|
-
_version$split2$ = _version$split2[0],
|
108
|
-
minVersion = _version$split2$ === void 0 ? '' : _version$split2$,
|
109
|
-
_version$split2$2 = _version$split2[1],
|
110
|
-
maxVersion = _version$split2$2 === void 0 ? '' : _version$split2$2;
|
111
|
-
isMatchVersion = isVersionInRange(currentVersion, minVersion, maxVersion);
|
112
|
-
} else if (version.indexOf(',') !== -1) {
|
113
|
-
// , 枚举匹配
|
114
|
-
var versionList = version.split(',');
|
115
|
-
isMatchVersion = versionList.includes(currentVersion);
|
116
|
-
} else {
|
117
|
-
isMatchVersion = version === currentVersion;
|
118
|
-
}
|
119
|
-
return value && isMatchPlatform && isMatchVersion;
|
120
45
|
}
|
package/package.json
CHANGED
File without changes
|