@alipay/ams-checkout 1.11.0 → 1.12.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/config/request.js +3 -3
- 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.d.ts +1 -0
- package/esm/core/component/index.js +14 -6
- package/esm/core/instance/index.d.ts +8 -1
- package/esm/core/instance/index.js +20 -13
- 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/component.popup.style.js +1 -1
- package/esm/plugin/component/index.d.ts +1 -2
- package/esm/plugin/component/index.js +137 -83
- 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/request/index.js +8 -14
- package/esm/types/index.d.ts +58 -3
- package/esm/types/index.js +18 -0
- 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 +3 -1
- package/esm/util/versionCompare.js +75 -0
- package/package.json +1 -1
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;
|
@@ -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";
|
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,4 +3,6 @@
|
|
3
3
|
* @param v1
|
4
4
|
* @param v2
|
5
5
|
*/
|
6
|
-
export declare function compareVersion(v1: string, v2: string):
|
6
|
+
export declare function compareVersion(v1: string, v2: string): 0 | 1 | -1;
|
7
|
+
export declare function isVersionInRange(currentVersion: any, minVersion: any, maxVersion: any): boolean;
|
8
|
+
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,73 @@ export function compareVersion(v1, v2) {
|
|
42
48
|
} else {
|
43
49
|
return 1;
|
44
50
|
}
|
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;
|
45
120
|
}
|