@alipay/ams-checkout 1.20.1 → 1.21.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/index.d.ts +11 -0
- package/esm/config/index.js +20 -1
- package/esm/constant/index.d.ts +5 -0
- package/esm/constant/index.js +5 -0
- package/esm/core/component/address.d.ts +8 -0
- package/esm/core/component/address.js +72 -0
- package/esm/core/component/index.d.ts +5 -2
- package/esm/core/component/index.js +70 -55
- package/esm/core/instance/index.js +9 -1
- package/esm/index.d.ts +8 -8
- package/esm/index.js +44 -8
- package/esm/plugin/applepay/component.js +1 -1
- package/esm/plugin/component/cashierApp.d.ts +3 -3
- package/esm/plugin/component/cashierApp.js +33 -3
- package/esm/plugin/component/channel.js +1 -0
- package/esm/plugin/component/component.inline.style.d.ts +8 -9
- package/esm/plugin/component/component.inline.style.js +87 -6
- package/esm/plugin/component/component.popup.style.d.ts +1 -0
- package/esm/plugin/component/component.popup.style.js +3 -0
- package/esm/plugin/component/index.d.ts +3 -1
- package/esm/plugin/component/index.js +123 -88
- package/esm/plugin/component/popupWindow.style.d.ts +5 -2
- package/esm/plugin/component/popupWindow.style.js +70 -14
- package/esm/plugin/payment-element/utils.d.ts +2 -0
- package/esm/plugin/payment-element/utils.js +6 -0
- package/esm/plugin/paypal/index.js +1 -0
- package/esm/plugin/type.d.ts +1 -0
- package/esm/types/index.d.ts +92 -4
- package/esm/types/index.js +14 -0
- package/esm/util/security.d.ts +1 -0
- package/esm/util/security.js +1 -1
- package/package.json +1 -1
package/esm/index.js
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
5
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
3
6
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
4
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
@@ -18,10 +21,11 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
18
21
|
* 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
|
19
22
|
* 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.
|
20
23
|
*/
|
24
|
+
import { AMSAutoDebitAppVersion, AMSCashierPaymentAppVersion, AMSCheckoutAppVersion, AMSEasyPayAppVersion, AMSPaymentElementAppVersion, AMSVaultingAppVersion, ADDRESSElementAppVersion } from "./config/index";
|
21
25
|
import { AMSComponent } from "./core/component/index";
|
22
|
-
import {
|
23
|
-
import { productSceneEnum } from "./types
|
24
|
-
import {
|
26
|
+
import { AddressComponent } from "./core/component/address";
|
27
|
+
import { componentSignEnum, productSceneEnum } from "./types";
|
28
|
+
import { Logger, LogConfig } from "./util/logger";
|
25
29
|
var logger = new Logger(LogConfig, true);
|
26
30
|
export { AMSCheckoutPage } from "./core/component/ckp";
|
27
31
|
export * from "./types";
|
@@ -32,7 +36,9 @@ export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
|
32
36
|
var _this;
|
33
37
|
var productSceneVersion = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '1.0';
|
34
38
|
_classCallCheck(this, AMSCheckout);
|
35
|
-
_this = _super.call(this,
|
39
|
+
_this = _super.call(this, _objectSpread({
|
40
|
+
appVersion: AMSCheckoutAppVersion
|
41
|
+
}, _options));
|
36
42
|
_this.preloadComponent(channelType, productSceneVersion);
|
37
43
|
return _this;
|
38
44
|
}
|
@@ -44,7 +50,8 @@ export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
|
44
50
|
function AMSAutoDebit(options) {
|
45
51
|
_classCallCheck(this, AMSAutoDebit);
|
46
52
|
var _options = Object.assign({}, options, {
|
47
|
-
product: productSceneEnum.AUTO_DEBIT
|
53
|
+
product: productSceneEnum.AUTO_DEBIT,
|
54
|
+
appVersion: AMSAutoDebitAppVersion
|
48
55
|
});
|
49
56
|
return _super2.call(this, _options, [componentSignEnum.AUTO_DEBIT_WALLET]);
|
50
57
|
}
|
@@ -68,7 +75,8 @@ export var AMSEasyPay = /*#__PURE__*/function (_AMSCheckout3) {
|
|
68
75
|
function AMSEasyPay(options) {
|
69
76
|
_classCallCheck(this, AMSEasyPay);
|
70
77
|
var _options = Object.assign({}, options, {
|
71
|
-
product: productSceneEnum.EASY_PAY
|
78
|
+
product: productSceneEnum.EASY_PAY,
|
79
|
+
appVersion: AMSEasyPayAppVersion
|
72
80
|
});
|
73
81
|
var currentProductSceneVersion = '1.0';
|
74
82
|
try {
|
@@ -99,7 +107,8 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout4) {
|
|
99
107
|
function AMSCashierPayment(options) {
|
100
108
|
_classCallCheck(this, AMSCashierPayment);
|
101
109
|
var _options = Object.assign({}, options, {
|
102
|
-
product: productSceneEnum.CASHIER_PAYMENT
|
110
|
+
product: productSceneEnum.CASHIER_PAYMENT,
|
111
|
+
appVersion: AMSCashierPaymentAppVersion
|
103
112
|
});
|
104
113
|
var currentChannelType;
|
105
114
|
try {
|
@@ -130,10 +139,37 @@ export var AMSVaulting = /*#__PURE__*/function (_AMSCheckout5) {
|
|
130
139
|
function AMSVaulting(options) {
|
131
140
|
_classCallCheck(this, AMSVaulting);
|
132
141
|
var _options = Object.assign({}, options, {
|
133
|
-
product: productSceneEnum.VAULTING
|
142
|
+
product: productSceneEnum.VAULTING,
|
143
|
+
appVersion: AMSVaultingAppVersion
|
134
144
|
});
|
135
145
|
return _super6.call(this, _options, [componentSignEnum.CASHIER_PAYMENT_CARD]);
|
136
146
|
}
|
137
147
|
return _createClass(AMSVaulting);
|
138
148
|
}(AMSCheckout);
|
149
|
+
export var AntomElement = /*#__PURE__*/function (_AMSCheckout6) {
|
150
|
+
_inherits(AntomElement, _AMSCheckout6);
|
151
|
+
var _super7 = _createSuper(AntomElement);
|
152
|
+
function AntomElement(options) {
|
153
|
+
_classCallCheck(this, AntomElement);
|
154
|
+
var _options = Object.assign({}, options, {
|
155
|
+
product: productSceneEnum.ELEMENT_PAYMENT,
|
156
|
+
appVersion: AMSPaymentElementAppVersion
|
157
|
+
});
|
158
|
+
return _super7.call(this, _options, [componentSignEnum.ELEMENT_PAYMENT]);
|
159
|
+
}
|
160
|
+
return _createClass(AntomElement);
|
161
|
+
}(AMSCheckout);
|
162
|
+
export var AddressElement = /*#__PURE__*/function (_AddressComponent) {
|
163
|
+
_inherits(AddressElement, _AddressComponent);
|
164
|
+
var _super8 = _createSuper(AddressElement);
|
165
|
+
function AddressElement(options) {
|
166
|
+
_classCallCheck(this, AddressElement);
|
167
|
+
var _options = Object.assign({}, options, {
|
168
|
+
product: productSceneEnum.ELEMENT_ADDRESS,
|
169
|
+
appVersion: ADDRESSElementAppVersion
|
170
|
+
});
|
171
|
+
return _super8.call(this, _options);
|
172
|
+
}
|
173
|
+
return _createClass(AddressElement);
|
174
|
+
}(AddressComponent);
|
139
175
|
export default AMSCheckout;
|
@@ -84,7 +84,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
|
|
84
84
|
}, {
|
85
85
|
biz: 'sdk',
|
86
86
|
type: 'funnel',
|
87
|
-
success: eventCodeEnum.
|
87
|
+
success: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL === (state === null || state === void 0 ? void 0 : state.code),
|
88
88
|
code: state === null || state === void 0 ? void 0 : state.code,
|
89
89
|
errorCode: state === null || state === void 0 || (_state$result = state.result) === null || _state$result === void 0 ? void 0 : _state$result.errorCode,
|
90
90
|
errorMessage: state === null || state === void 0 || (_state$result2 = state.result) === null || _state$result2 === void 0 ? void 0 : _state$result2.errorMessage,
|
@@ -16,13 +16,13 @@ export declare const getIframeUrl: (iframeParams: {
|
|
16
16
|
productSceneVersion: string;
|
17
17
|
environment: string;
|
18
18
|
appVersion: string;
|
19
|
-
extendInfo
|
20
|
-
locale
|
19
|
+
extendInfo?: string;
|
20
|
+
locale?: string;
|
21
21
|
instanceId: string;
|
22
22
|
renderDisplayType: renderDisplayTypeEnum;
|
23
23
|
isPreload?: string;
|
24
24
|
hostSign?: string;
|
25
|
-
mid
|
25
|
+
mid?: string;
|
26
26
|
}) => {
|
27
27
|
path: string;
|
28
28
|
locationSearch: string;
|
@@ -1,4 +1,10 @@
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
4
|
+
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); }
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
7
|
+
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; }
|
2
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
3
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
4
10
|
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); }
|
@@ -9,8 +15,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
9
15
|
* 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
|
10
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.
|
11
17
|
*/
|
12
|
-
import { marmotMap, sdkVersion } from "../../config/index";
|
13
|
-
import { componentSignEnum } from "../../types";
|
18
|
+
import { elementAppMarmotMap, marmotMap, sdkVersion } from "../../config/index";
|
19
|
+
import { componentSignEnum, ComponentSignEnumV2 } from "../../types";
|
14
20
|
import { isDebugLog } from "../../util/debug";
|
15
21
|
import { queryParse, serialize } from "../../util/index";
|
16
22
|
import { Logger } from "../../util/logger";
|
@@ -52,7 +58,8 @@ var getAppVersion = function getAppVersion(_extendInfo, productScene, mid) {
|
|
52
58
|
}
|
53
59
|
};
|
54
60
|
var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
|
55
|
-
var
|
61
|
+
var _signSupportMap;
|
62
|
+
var signSupportMap = (_signSupportMap = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), componentSignEnum.AUTO_DEBIT_PAY_WALLET, ['']), componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), componentSignEnum.CASHIER_PAYMENT_APM, ['1.0']), componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), componentSignEnum.EASY_PAY_APM, ['2.0']), componentSignEnum.VAULTING_CARD, ['1.0']), componentSignEnum.ELEMENT_PAYMENT, ['1.0']), _defineProperty(_defineProperty(_signSupportMap, componentSignEnum.ELEMENT_ADDRESS, ['1.0']), componentSignEnum.CHECKOUT_PAYMENT, ['1.0.0']));
|
56
63
|
var supportProductSceneVersion = signSupportMap[componentSign];
|
57
64
|
// 从左到右,从旧到新
|
58
65
|
var isSupport = supportProductSceneVersion.find(function (it) {
|
@@ -90,6 +97,27 @@ export var getAppPath = function getAppPath() {
|
|
90
97
|
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
|
91
98
|
return urlTestHost;
|
92
99
|
}
|
100
|
+
// 地址应用特殊处理
|
101
|
+
if (componentSign === componentSignEnum.ELEMENT_ADDRESS) {
|
102
|
+
return "".concat(elementAppMarmotMap[environment], "/element-address/").concat(finalAppVersion, "/pages/address/index.html");
|
103
|
+
}
|
104
|
+
// element应用特殊处理
|
105
|
+
if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign)) {
|
106
|
+
// element又分为express_checkout模式和普通模式, express_checkout 模式在扩展参数是返回expressCheckout=true
|
107
|
+
var isExpressCheckout = false;
|
108
|
+
try {
|
109
|
+
// expressCheckout可能出现string(false) JSON.parse再转一次
|
110
|
+
isExpressCheckout = JSON.parse(JSON.parse(extendInfo).expressCheckout);
|
111
|
+
} catch (error) {
|
112
|
+
// 遇到JSON解析错误,默认false
|
113
|
+
}
|
114
|
+
if (isExpressCheckout) {
|
115
|
+
// express_checkout模式走单独映射
|
116
|
+
return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/express_checkout/index.html");
|
117
|
+
} else {
|
118
|
+
return "".concat(elementAppMarmotMap[environment], "/elements/").concat(finalAppVersion, "/pages/").concat(productScene.toLowerCase(), "/index.html");
|
119
|
+
}
|
120
|
+
}
|
93
121
|
return "".concat(marmotMap[environment], "/").concat(componentSign, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
94
122
|
};
|
95
123
|
export var getAppDomain = function getAppDomain(domainParams) {
|
@@ -189,6 +217,8 @@ export var createIframe = function createIframe(mode, platform) {
|
|
189
217
|
iframe.style.border = none;
|
190
218
|
iframe.style.opacity = none;
|
191
219
|
iframe.style.overflow = 'hidden';
|
220
|
+
// iframe设置支持第三方支付
|
221
|
+
iframe.allow = 'payment';
|
192
222
|
return iframe;
|
193
223
|
};
|
194
224
|
export var createPreloadIframe = function createPreloadIframe(channelType, version) {
|
@@ -24,6 +24,7 @@ export function getChannelBehavior(paymentSessionMetaData) {
|
|
24
24
|
createIframeNode: true,
|
25
25
|
loadApp: true,
|
26
26
|
allowClickOutsideClose: false,
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
27
28
|
buildSubmitPayExtParams: function buildSubmitPayExtParams(params) {
|
28
29
|
return {};
|
29
30
|
}
|
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
*/
|
8
|
-
import { platformEnum } from '../../types';
|
1
|
+
import { componentSignEnum, platformEnum } from '../../types';
|
2
|
+
interface Options {
|
3
|
+
componentSign?: componentSignEnum;
|
4
|
+
type: 'tabs' | 'Accordion';
|
5
|
+
isExpressCheckout?: boolean;
|
6
|
+
}
|
9
7
|
export declare const inlineComponentAddCss: () => void;
|
10
|
-
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum) => void;
|
8
|
+
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum, options: Options) => void;
|
11
9
|
export declare const createInlineBaseElement: (selector: string) => HTMLDivElement;
|
10
|
+
export {};
|
@@ -5,10 +5,11 @@
|
|
5
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
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
|
-
import {
|
9
|
-
import {
|
8
|
+
import { COMPONENT_CONTAINER_ID, COMPONENT_IFRAME_TAG_ID, INLINE_BASE_STYLE_ID, INLINE_IMG_CLASSNAME, LOADING_ID } from "../../constant";
|
9
|
+
import { componentSignEnum, platformEnum } from "../../types";
|
10
10
|
import { amsSetSize } from "../../util";
|
11
|
-
|
11
|
+
// border-radius: 8px;
|
12
|
+
var inlineComponentCss = "#".concat(COMPONENT_IFRAME_TAG_ID, "-desktop{\n position: absolute;\n top: 0;\n left: 0;\n}\n#").concat(COMPONENT_IFRAME_TAG_ID, "-mobile{\n position: absolute;\n top: 0;\n left: 0;\n}\n.").concat(COMPONENT_CONTAINER_ID, "-inline{\n width: 100%;\n height: auto;\n position: relative;\n line-height: 0;\n display: flex;\n}\n#").concat(LOADING_ID, "{\n width: 100%;\n flex: 1;\n}\n.").concat(INLINE_IMG_CLASSNAME, "{\n width: 100%;\n height: auto;\n object-fit: contain;\n box-sizing: border-box;\n}\n.").concat(INLINE_IMG_CLASSNAME, "-mobile{\n padding: 0 0.16em;\n}\n.").concat(INLINE_IMG_CLASSNAME, "-desktop{}\n");
|
12
13
|
export var inlineComponentAddCss = function inlineComponentAddCss() {
|
13
14
|
var style = document.createElement('style');
|
14
15
|
style.id = 'ams-inline-component-style';
|
@@ -16,11 +17,91 @@ export var inlineComponentAddCss = function inlineComponentAddCss() {
|
|
16
17
|
style.innerHTML = inlineComponentCss;
|
17
18
|
document.head.appendChild(style);
|
18
19
|
};
|
19
|
-
|
20
|
+
/**
|
21
|
+
* @description componentSignEnum.ELEMENT_PAYMENT特殊处理
|
22
|
+
* @param {Options['type']} type
|
23
|
+
*/
|
24
|
+
var renderElementPayment = function renderElementPayment(type) {
|
25
|
+
var spliceStr = function spliceStr() {
|
26
|
+
var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
27
|
+
return arr.reduce(function (pre, cur) {
|
28
|
+
return pre += cur;
|
29
|
+
}, '');
|
30
|
+
};
|
31
|
+
var commonDom = function commonDom(children) {
|
32
|
+
var viewBox = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0 0 560 256';
|
33
|
+
var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 256;
|
34
|
+
return "<svg id=\"".concat(INLINE_IMG_CLASSNAME, "-").concat(type, "\" width=\"100%\" height=\"").concat(height, "\" viewBox=\"").concat(viewBox, "\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\" preserveAspectRatio=\"none\">\n ").concat(spliceStr(children), "\n <animate xlink:href=\"#").concat(INLINE_IMG_CLASSNAME, "-").concat(type, "\" attributeName=\"opacity\" values=\"0.5; 1; 0.5\" begin=\"0s\" dur=\"1s\" repeatCount=\"indefinite\"></animate>\n </svg>");
|
35
|
+
};
|
36
|
+
var creatRect = function creatRect(_ref) {
|
37
|
+
var _ref$x = _ref.x,
|
38
|
+
x = _ref$x === void 0 ? 0 : _ref$x,
|
39
|
+
_ref$y = _ref.y,
|
40
|
+
y = _ref$y === void 0 ? 0 : _ref$y,
|
41
|
+
_ref$fill = _ref.fill,
|
42
|
+
fill = _ref$fill === void 0 ? 'black' : _ref$fill,
|
43
|
+
_ref$width = _ref.width,
|
44
|
+
width = _ref$width === void 0 ? 560 : _ref$width,
|
45
|
+
_ref$height = _ref.height,
|
46
|
+
height = _ref$height === void 0 ? 32 : _ref$height,
|
47
|
+
_ref$rx = _ref.rx,
|
48
|
+
rx = _ref$rx === void 0 ? 4 : _ref$rx;
|
49
|
+
return "<rect fill-opacity=\"0.04\" x=\"".concat(x, "\" y=\"").concat(y, "\" width=\"").concat(width, "\" height=\"").concat(height, "\" rx=\"").concat(rx, "\" fill=\"").concat(fill, "\"/>");
|
50
|
+
};
|
51
|
+
var result = [creatRect({
|
52
|
+
fill: 'white'
|
53
|
+
}), creatRect({
|
54
|
+
y: 4
|
55
|
+
}), creatRect({
|
56
|
+
y: 48,
|
57
|
+
height: 64
|
58
|
+
}), creatRect({
|
59
|
+
y: 128
|
60
|
+
}), creatRect({
|
61
|
+
y: 176
|
62
|
+
}), creatRect({
|
63
|
+
y: 224
|
64
|
+
})];
|
65
|
+
if (type === 'tabs') {
|
66
|
+
result = [creatRect({
|
67
|
+
fill: 'white',
|
68
|
+
width: 358,
|
69
|
+
height: 305
|
70
|
+
}), creatRect({
|
71
|
+
y: 4,
|
72
|
+
width: '50%',
|
73
|
+
height: 73
|
74
|
+
}), creatRect({
|
75
|
+
x: '51%',
|
76
|
+
y: 4,
|
77
|
+
height: 73
|
78
|
+
}), creatRect({
|
79
|
+
y: 96,
|
80
|
+
height: 64
|
81
|
+
}), creatRect({
|
82
|
+
y: 178
|
83
|
+
}), creatRect({
|
84
|
+
y: 228
|
85
|
+
}), creatRect({
|
86
|
+
y: 276
|
87
|
+
})];
|
88
|
+
}
|
89
|
+
var viewBox = {
|
90
|
+
view: type === 'tabs' ? '0 0 358 305' : '0 0 560 256',
|
91
|
+
height: type === 'tabs' ? 305 : 256
|
92
|
+
};
|
93
|
+
return commonDom(result, viewBox.view, viewBox.height);
|
94
|
+
};
|
95
|
+
export var addInlineLoading = function addInlineLoading(_selector, platform, options) {
|
20
96
|
var loading = document.createElement('div');
|
21
97
|
loading.id = LOADING_ID;
|
22
|
-
if (
|
23
|
-
|
98
|
+
if (options.componentSign === componentSignEnum.ELEMENT_PAYMENT) {
|
99
|
+
if (options.isExpressCheckout) {
|
100
|
+
loading.innerHTML = '';
|
101
|
+
} else {
|
102
|
+
loading.innerHTML = renderElementPayment(options === null || options === void 0 ? void 0 : options.type);
|
103
|
+
}
|
104
|
+
} else if (platform === platformEnum.desktop) loading.innerHTML = "<svg class=\"".concat(INLINE_IMG_CLASSNAME, " ").concat(INLINE_IMG_CLASSNAME, "-").concat(platform, "\" width=\"740\" height=\"360\" viewBox=\"0 0 740 360\" fill=\"none\" xmlns=\"\">\n <rect width=\"740\" height=\"360\" rx=\"12\" fill=\"#F6F6F6\"/>\n <rect opacity=\"0.7\" x=\"44\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"94\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"144\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M136 100H48C43.5817 100 40 103.582 40 108C40 112.418 43.5817 116 48 116H136C140.418 116 144 112.418 144 108C144 103.582 140.418 100 136 100Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M682 126H58C48.0589 126 40 134.059 40 144C40 153.941 48.0589 162 58 162H682C691.941 162 700 153.941 700 144C700 134.059 691.941 126 682 126Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M682 182H58C48.0589 182 40 190.059 40 200C40 209.941 48.0589 218 58 218H682C691.941 218 700 209.941 700 200C700 190.059 691.941 182 682 182Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M504 274H64C52.9543 274 44 282.954 44 294C44 305.046 52.9543 314 64 314H504C515.046 314 524 305.046 524 294C524 282.954 515.046 274 504 274Z\" fill=\"#E1E6ED\"/>\n </g>\n </svg>");else if (platform === platformEnum.mobile) loading.innerHTML = "<svg class=\"".concat(INLINE_IMG_CLASSNAME, " ").concat(INLINE_IMG_CLASSNAME, "-").concat(platform, "\" width=\"358\" height=\"186\" viewBox=\"0 0 358 186\" fill=\"none\" xmlns=\"\">\n <g clip-path=\"url(#clip0_2543_91192)\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n <g clip-path=\"url(#clip1_2543_91192)\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n <rect width=\"358\" height=\"40\" fill=\"white\"/>\n <rect opacity=\"0.7\" x=\"4\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"54\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"104\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <g clip-path=\"url(#clip2_2543_91192)\">\n <rect width=\"358\" height=\"120\" transform=\"translate(0 66)\" fill=\"white\"/>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M95 66H9C4.02944 66 0 70.0294 0 75C0 79.9706 4.02943 84 9 84H95C99.9706 84 104 79.9706 104 75C104 70.0294 99.9706 66 95 66Z\" fill=\"#E1E6ED\"/>\n </g>\n <g clip-path=\"url(#clip3_2543_91192)\">\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M340 94H18C8.05888 94 0 102.059 0 112C0 121.941 8.05887 130 18 130H340C349.941 130 358 121.941 358 112C358 102.059 349.941 94 340 94Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M340 150H18C8.05888 150 0 158.059 0 168C0 177.941 8.05887 186 18 186H340C349.941 186 358 177.941 358 168C358 158.059 349.941 150 340 150Z\" fill=\"#E1E6ED\"/>\n </g>\n </g>\n </g>\n </g>\n </g>\n <defs>\n <clipPath id=\"clip0_2543_91192\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n </clipPath>\n <clipPath id=\"clip1_2543_91192\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n </clipPath>\n <clipPath id=\"clip2_2543_91192\">\n <rect width=\"358\" height=\"120\" fill=\"white\" transform=\"translate(0 66)\"/>\n </clipPath>\n <clipPath id=\"clip3_2543_91192\">\n <rect width=\"358\" height=\"92\" fill=\"white\" transform=\"translate(0 94)\"/>\n </clipPath>\n </defs>\n </svg>\n ");
|
24
105
|
if (_selector) _selector.appendChild(loading);
|
25
106
|
var loadingDom = document.getElementById(LOADING_ID);
|
26
107
|
amsSetSize(null, loadingDom);
|
@@ -168,4 +168,7 @@ export var handleDeclareInfo = function handleDeclareInfo(_ref) {
|
|
168
168
|
} catch (error) {
|
169
169
|
console.error(error);
|
170
170
|
}
|
171
|
+
};
|
172
|
+
export var slideInAndOutKeyframes = function slideInAndOutKeyframes(id, height) {
|
173
|
+
return "@keyframes ".concat(id, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(height, "px;\n }\n }\n @keyframes ").concat(id, "-slide-out {\n 0% {\n height: ").concat(height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
|
171
174
|
};
|
@@ -27,7 +27,9 @@ export default class ComponentApp {
|
|
27
27
|
private _multipleCallbackEvents;
|
28
28
|
_merchantAppointParam: IMerchantAppointParam;
|
29
29
|
private _webAppHeartBeatTimeoutFn;
|
30
|
-
constructor(
|
30
|
+
constructor(componentOption?: {
|
31
|
+
appVersion?: string;
|
32
|
+
});
|
31
33
|
/**
|
32
34
|
* @description Cancel listening and destroy the dom
|
33
35
|
*/
|