@alipay/ams-checkout 0.0.1691743027-dev.8 → 0.0.1691995963-dev.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 +15 -1
- package/esm/config/index.js +62 -9
- package/esm/constant/index.d.ts +32 -54
- package/esm/constant/index.js +32 -54
- package/esm/core/component/index.d.ts +9 -23
- package/esm/core/component/index.js +98 -161
- package/esm/core/drop-in/index.d.ts +1 -1
- package/esm/core/instance/index.d.ts +23 -6
- package/esm/core/instance/index.js +75 -31
- package/esm/index.d.ts +10 -4
- package/esm/index.js +30 -8
- package/esm/plugin/component/cashierApp.d.ts +6 -5
- package/esm/plugin/component/cashierApp.js +64 -48
- package/esm/plugin/component/{component.inline.style.d.ts → component.style.d.ts} +1 -4
- package/esm/plugin/component/component.style.js +15 -0
- package/esm/plugin/component/index.d.ts +33 -30
- package/esm/plugin/component/index.js +349 -248
- package/esm/plugin/drop-in/index.js +1 -1
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +7 -8
- package/esm/request/utils.d.ts +3 -3
- package/esm/request/utils.js +4 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +37 -96
- package/esm/types/index.js +52 -92
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +4 -6
- package/esm/util/index.js +5 -22
- package/esm/util/mock.js +2 -1
- package/package.json +1 -1
- package/esm/config/request.d.ts +0 -21
- package/esm/config/request.js +0 -67
- package/esm/image/skeleton.svg +0 -18
- package/esm/plugin/component/component.inline.style.js +0 -38
- package/esm/plugin/component/component.popup.style.d.ts +0 -12
- package/esm/plugin/component/component.popup.style.js +0 -163
package/esm/index.js
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
2
|
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
3
|
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
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
5
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
6
4
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
7
5
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
8
6
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
@@ -11,6 +9,9 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
11
9
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
12
10
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
13
11
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
12
|
+
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; }
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
14
15
|
/**
|
15
16
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
16
17
|
*
|
@@ -18,17 +19,38 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
18
19
|
* 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
20
|
* 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
21
|
*/
|
21
|
-
import {
|
22
|
+
import { createComponent, mixinComponentConstructor } from "./core/component/index";
|
23
|
+
import { confirmPayment, createPayment, mixinDropInConstructor, _subscribeFromCheckoutPlugin } from "./core/drop-in/index";
|
24
|
+
import AMSSDK from "./core/instance";
|
22
25
|
export * from "./types";
|
23
|
-
export var AMSCheckout = /*#__PURE__*/function (
|
24
|
-
_inherits(AMSCheckout,
|
26
|
+
export var AMSCheckout = /*#__PURE__*/function (_AMSSDK) {
|
27
|
+
_inherits(AMSCheckout, _AMSSDK);
|
25
28
|
var _super = _createSuper(AMSCheckout);
|
26
|
-
function AMSCheckout() {
|
29
|
+
function AMSCheckout(options) {
|
30
|
+
var _this;
|
27
31
|
_classCallCheck(this, AMSCheckout);
|
28
|
-
|
32
|
+
_this = _super.call(this, options);
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "createComponent", void 0);
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "createPayment", void 0);
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "confirmPayment", void 0);
|
36
|
+
Object.defineProperty(_assertThisInitialized(_this), 'createComponent', {
|
37
|
+
value: createComponent
|
38
|
+
});
|
39
|
+
Object.defineProperty(_assertThisInitialized(_this), 'createPayment', {
|
40
|
+
value: createPayment
|
41
|
+
});
|
42
|
+
Object.defineProperty(_assertThisInitialized(_this), 'confirmPayment', {
|
43
|
+
value: confirmPayment
|
44
|
+
});
|
45
|
+
Object.defineProperty(_assertThisInitialized(_this), '_subscribeFromCheckoutPlugin', {
|
46
|
+
value: _subscribeFromCheckoutPlugin
|
47
|
+
});
|
48
|
+
mixinComponentConstructor(options, _assertThisInitialized(_this));
|
49
|
+
mixinDropInConstructor(options, _assertThisInitialized(_this));
|
50
|
+
return _this;
|
29
51
|
}
|
30
52
|
return _createClass(AMSCheckout);
|
31
|
-
}(
|
53
|
+
}(AMSSDK);
|
32
54
|
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
33
55
|
_inherits(AMSAutoDebit, _AMSCheckout);
|
34
56
|
var _super2 = _createSuper(AMSAutoDebit);
|
@@ -1,14 +1,15 @@
|
|
1
|
-
import {
|
2
|
-
export declare const getAppPath: (environment: string | undefined, appVersion: string,
|
1
|
+
import { Ianalytics } from '../../types';
|
2
|
+
export declare const getAppPath: (environment: string | undefined, appVersion: string, componentName: string, productSceneVersion: string, extendInfo: string) => any;
|
3
3
|
export declare const getAppDomain: (domainParams: {
|
4
4
|
environment: string;
|
5
5
|
appVersion: string;
|
6
|
-
|
6
|
+
componentName: string;
|
7
7
|
productSceneVersion: string;
|
8
8
|
extendInfo: string;
|
9
9
|
}) => string;
|
10
10
|
export declare const getIframeUrl: (iframeParams: {
|
11
|
-
|
11
|
+
componentName: string;
|
12
|
+
appearance: Record<string, string>;
|
12
13
|
analytics?: Ianalytics;
|
13
14
|
productSceneVersion: string;
|
14
15
|
environment: string;
|
@@ -20,4 +21,4 @@ export declare const getIframeUrl: (iframeParams: {
|
|
20
21
|
/**
|
21
22
|
* @description Create iframe
|
22
23
|
*/
|
23
|
-
export declare const createIframe: (mode: string
|
24
|
+
export declare const createIframe: (mode: string) => HTMLIFrameElement;
|
@@ -9,57 +9,74 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
9
9
|
* 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
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
|
-
import {
|
13
|
-
import {
|
12
|
+
import { sdkVersion } from "../../config/index";
|
13
|
+
import { componentNameEnum } from "../../types";
|
14
14
|
import { getViewPort, queryParse, serialize } from "../../util/index";
|
15
|
-
var getAppVersion = function getAppVersion(_extendInfo) {
|
16
|
-
try {
|
17
|
-
var info = JSON.parse(_extendInfo);
|
18
|
-
return info.versionMap.web[sdkVersion].targetWebVerison;
|
19
|
-
} catch (error) {
|
20
|
-
return '';
|
21
|
-
}
|
22
|
-
};
|
23
|
-
var getFinalProductSceneVersion = function getFinalProductSceneVersion(componentSign, productSceneVersion) {
|
24
|
-
var _signSupportMap;
|
25
|
-
var signSupportMap = (_signSupportMap = {}, _defineProperty(_signSupportMap, componentSignEnum.NONE, ['']), _defineProperty(_signSupportMap, componentSignEnum.AUTO_DEBIT_WALLET, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_BANK, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.CASHIER_PAYMENT_CARD, ['1.0']), _defineProperty(_signSupportMap, componentSignEnum.EASY_PAY_WALLET, ['1.0', '2.0']), _signSupportMap);
|
26
|
-
var supportProductSceneVersion = signSupportMap[componentSign];
|
27
|
-
// 从左到右,从旧到新
|
28
|
-
var isSupport = supportProductSceneVersion.find(function (it) {
|
29
|
-
return it === productSceneVersion;
|
30
|
-
});
|
31
|
-
var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
|
32
|
-
return isSupport ? productSceneVersion : finalProductSceneVersion;
|
33
|
-
};
|
34
15
|
export var getAppPath = function getAppPath() {
|
16
|
+
var _componentMap;
|
35
17
|
var environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
36
18
|
var appVersion = arguments.length > 1 ? arguments[1] : undefined;
|
37
|
-
var
|
19
|
+
var componentName = arguments.length > 2 ? arguments[2] : undefined;
|
38
20
|
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
39
21
|
var extendInfo = arguments.length > 4 ? arguments[4] : undefined;
|
40
22
|
var _ref = queryParse() || {},
|
41
23
|
urlTestHost = _ref.host;
|
42
|
-
var
|
43
|
-
var
|
44
|
-
|
24
|
+
var host = '';
|
25
|
+
var getAppVersion = function getAppVersion(_extendInfo) {
|
26
|
+
try {
|
27
|
+
var info = JSON.parse(_extendInfo);
|
28
|
+
return info.versionMap.web[sdkVersion].targetWebVerison || appVersion;
|
29
|
+
} catch (error) {
|
30
|
+
return appVersion;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
var marmptMap = {
|
34
|
+
dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
|
35
|
+
sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
|
36
|
+
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
|
37
|
+
sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
38
|
+
light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
39
|
+
prod: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app'
|
40
|
+
};
|
41
|
+
var finalAppVersion = getAppVersion(extendInfo);
|
42
|
+
var getFinalProductSceneVersion = function getFinalProductSceneVersion(supportProductSceneVersion) {
|
43
|
+
// 从左到右,从旧到新
|
44
|
+
var isSupport = supportProductSceneVersion.find(function (it) {
|
45
|
+
return it === productSceneVersion;
|
46
|
+
});
|
47
|
+
var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
|
48
|
+
if (isSupport) finalProductSceneVersion = productSceneVersion;
|
49
|
+
return finalProductSceneVersion;
|
50
|
+
};
|
51
|
+
var componentMap = (_componentMap = {}, _defineProperty(_componentMap, componentNameEnum.card, function () {
|
52
|
+
host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.card, "/index.").concat(finalAppVersion, ".html");
|
53
|
+
}), _defineProperty(_componentMap, componentNameEnum.easyPay, function () {
|
54
|
+
var finalProductSceneVersion = getFinalProductSceneVersion(['1.0', '2.0']);
|
55
|
+
host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.easyPay, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
56
|
+
}), _defineProperty(_componentMap, componentNameEnum.autoDebit, function () {
|
57
|
+
var finalProductSceneVersion = getFinalProductSceneVersion(['1.0']);
|
58
|
+
host = "".concat(marmptMap[environment], "/").concat(componentNameEnum.autoDebit, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
59
|
+
}), _componentMap);
|
60
|
+
if (componentMap[componentName]) componentMap[componentName]();
|
45
61
|
// only for test while testurl?host=https://xxxxx.test.html
|
46
62
|
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(environment)) {
|
47
63
|
return urlTestHost;
|
48
64
|
}
|
49
|
-
return
|
65
|
+
return host;
|
50
66
|
};
|
51
67
|
export var getAppDomain = function getAppDomain(domainParams) {
|
52
68
|
var environment = domainParams.environment,
|
53
69
|
appVersion = domainParams.appVersion,
|
54
|
-
|
70
|
+
componentName = domainParams.componentName,
|
55
71
|
productSceneVersion = domainParams.productSceneVersion,
|
56
72
|
extendInfo = domainParams.extendInfo;
|
57
73
|
var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
|
58
|
-
var macth = reg.exec(getAppPath(environment, appVersion,
|
74
|
+
var macth = reg.exec(getAppPath(environment, appVersion, componentName, productSceneVersion, extendInfo));
|
59
75
|
return macth && macth[0] || '';
|
60
76
|
};
|
61
77
|
export var getIframeUrl = function getIframeUrl(iframeParams) {
|
62
|
-
var
|
78
|
+
var componentName = iframeParams.componentName,
|
79
|
+
appearance = iframeParams.appearance,
|
63
80
|
_iframeParams$analyti = iframeParams.analytics,
|
64
81
|
analytics = _iframeParams$analyti === void 0 ? {
|
65
82
|
enabled: true
|
@@ -70,7 +87,7 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
70
87
|
extendInfo = iframeParams.extendInfo,
|
71
88
|
locale = iframeParams.locale,
|
72
89
|
instanceId = iframeParams.instanceId;
|
73
|
-
var path = getAppPath(environment, appVersion,
|
90
|
+
var path = getAppPath(environment, appVersion, componentName, productSceneVersion, extendInfo || '');
|
74
91
|
var initialScale = 1;
|
75
92
|
var scale = getViewPort('initial-scale') || initialScale;
|
76
93
|
var _queryParse = queryParse(),
|
@@ -81,43 +98,42 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
81
98
|
_queryParse$groupId = _queryParse.groupId,
|
82
99
|
groupId = _queryParse$groupId === void 0 ? '' : _queryParse$groupId,
|
83
100
|
LOCAL_MOCK = _queryParse.LOCAL_MOCK;
|
84
|
-
var urlParams = Object.assign({
|
101
|
+
var urlParams = Object.assign({
|
85
102
|
locale: locale,
|
86
103
|
scale: scale,
|
87
104
|
instanceId: instanceId,
|
105
|
+
sandbox: environment === 'light_sandbox' || _light_sandbox === 'true' ? 'true' : 'false',
|
88
106
|
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
89
107
|
sdkVersion: sdkVersion,
|
90
|
-
refUrl: window.location.href
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
|
108
|
+
refUrl: window.location.href,
|
109
|
+
shadow: environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
|
110
|
+
requestHost: requestHost,
|
111
|
+
groupId: groupId,
|
112
|
+
LOCAL_MOCK: LOCAL_MOCK
|
113
|
+
}, appearance);
|
97
114
|
var locationSearch = serialize(urlParams);
|
98
115
|
return "".concat(path, "?").concat(locationSearch);
|
99
116
|
};
|
117
|
+
var getIframeId = function getIframeId(UIMode) {
|
118
|
+
var IdMap = {
|
119
|
+
dropin: 'checkout-dropin',
|
120
|
+
component: 'checkout-component'
|
121
|
+
};
|
122
|
+
return IdMap[UIMode] || 'checkout-component';
|
123
|
+
};
|
100
124
|
|
101
125
|
/**
|
102
126
|
* @description Create iframe
|
103
127
|
*/
|
104
|
-
export var createIframe = function createIframe(mode
|
105
|
-
var getIframeId = function getIframeId() {
|
106
|
-
var IdMap = {
|
107
|
-
dropin: "ams-checkout-dropin-".concat(platform),
|
108
|
-
component: "ams-checkout-component-".concat(platform)
|
109
|
-
};
|
110
|
-
return IdMap[mode] || 'ams-checkout-component';
|
111
|
-
};
|
128
|
+
export var createIframe = function createIframe(mode) {
|
112
129
|
var iframe = document.createElement('iframe');
|
113
|
-
var iframeId = getIframeId();
|
130
|
+
var iframeId = getIframeId(mode);
|
114
131
|
var none = '0';
|
115
132
|
var width = '100%';
|
116
133
|
iframe.id = iframeId;
|
117
134
|
iframe.style.height = none;
|
118
135
|
iframe.style.width = width;
|
119
136
|
iframe.style.border = none;
|
120
|
-
iframe.style.opacity = none;
|
121
137
|
iframe.style.overflow = 'hidden';
|
122
138
|
return iframe;
|
123
139
|
};
|
@@ -5,7 +5,4 @@
|
|
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
|
-
|
9
|
-
export declare const inlineComponentAddCss: () => void;
|
10
|
-
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum) => void;
|
11
|
-
export declare const createInlineBaseElement: (selector: string) => HTMLDivElement | undefined;
|
8
|
+
export declare function componentAddCSS(): void;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
+
*
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
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
|
+
* 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
|
+
*/
|
8
|
+
|
9
|
+
var componentCss = ".ams-component-container-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n}\n.ams-component-container-mobile-animation{\n animation: ams-component-container-slide-in 0.3s ease-in-out;\n}\n\n.ams-component-section-desktop {\n font-size: 0;\n}\n\n.ams-component-container-hidden-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n background-color: transparent;\n border-radius: 12px 12px 0 0;\n animation: ams-component-container-slide-out 0.26s ease-in forwards;\n overflow: hidden;\n}\n\n.ams-component-section-mobile {\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n font-size: 0;\n}\n\n.ams-component-container-desktop {\n display: block;\n width: 672px;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n transform-origin: 50% 50%;\n}\n.ams-component-container-desktop-animation{\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n@keyframes ams-component-container-zoom-out {\n 0% {\n transform: translateX(-50%) translateY(-50%) scale(1);\n opacity: 1\n }\n\n 80% {\n opacity: 0\n }\n \n 100% {\n opacity: 0;\n transform: translateX(-50%) translateY(-50%) scale(0.4);\n }\n}\n\n@keyframes ams-component-container-zoom-in {\n 0% {\n transform: translateX(-50%) translateY(-50%) scale(0.4);\n opacity: 0\n }\n\n 80% {\n opacity: 1\n }\n\n 100% {\n opacity: 1;\n transform: translateX(-50%) translateY(-50%) scale(1);\n }\n}\n\n.ams-component-container-hidden-desktop {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n animation-fill-mode: forwards;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n transform-origin: 50% 50%;\n}\n\n.ams-component-loading {\n width: 0.8em;\n height:0.8em;\n background: rgba(0, 0, 0, 0.5);\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-loading .line div:before,\n.ams-component-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: #fcfcfc;\n border-radius: 5.3px;\n}\n.ams-component-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n\n}\n\n.ams-component-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n\n.asm-component-close-block-desktop {\n position: absolute;\n width: 40px;\n height: 40px;\n right: 0;\n top: 0;\n cursor: pointer;\n}\n.asm-component-close-btn-desktop {\n width: 11px;\n height: 11px;\n object-fit: fill;\n position: absolute;\n right: 18.7px;\n top: 26.7px;\n}\n.asm-component-close-block-hidden {\n width: 0px !important;\n height: 0px !important;\n visibility: hidden;\n}\n.asm-component-close-block-mobile {\n position: absolute;\n width: 0.4em;\n height: 0.4em;\n right: 0;\n top: 0;\n cursor: pointer;\n z-index: 1009;\n}\n\n.asm-component-close-btn-mobile {\n width: 0.11em;\n height: 0.11em;\n object-fit: fill;\n position: absolute;\n right: 0.147em;\n top: 0.167em;\n}\n\n\n.ams-component-container-opacity{\n opacity: 1;\n}\n\n.ams-component-container-opacity:after{\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n display: block;\n content: \"\";\n z-index: 1010;\n background-color: rgba(0, 0, 0, 0.35);\n}\n\n#ams-component-retention {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transform-origin: 50%;\n height: auto;\n display: none;\n z-index: 1009;\n}\n\n.ams-component-retention-show {\n display: flex !important;\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-hidden {\n display: flex !important;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-mobile {\n width: 294px;\n border-radius: 12px;\n padding: 24px 0;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-desktop {\n width: 544px;\n border-radius: 12px;\n padding: 32px;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n@media screen and (max-width: 300px) {\n .ams-component-retention-mobile {\n transform: translate(-50%, -50%) scale(0.8);\n }\n}\n\n.ams-component-retention-title-mobile {\n width: 100%;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-title-desktop {\n text-align: left;\n width: 100%;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n}\n\n.ams-component-retention-sub-title-mobile {\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 8px;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-sub-title-desktop {\n text-align: left;\n font-style: normal;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 10px;\n}\n\n.ams-component-retention-btn-block-mobile {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n margin-top: 24px;\n padding: 0 24px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-btn-block-desktop {\n width: 100%;\n margin-top: 24px;\n}\n\n#ams-component-retention-remain {\n background: #0079FF;\n border-radius: 100px;\n font-style: normal;\n font-weight: 600;\n text-align: center;\n box-sizing: border-box;\n color: #FFFFFF;\n}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n}\n\n.ams-component-retention-remain-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n display: inline-block;\n padding: 0 24px;\n float: right;\n cursor: pointer;\n}\n\n#ams-component-retention-leave {\n border-radius: 100px;\n border: 1px solid #0079FF;\n font-style: normal;\n font-weight: 600;\n text-align: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-leave-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n margin-top: 12px;\n}\n\n.ams-component-retention-leave-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n display: inline-block;\n padding: 0 24px;\n float: right;\n margin-right: 16px;\n cursor: pointer;\n}\n\n";
|
10
|
+
export function componentAddCSS() {
|
11
|
+
var style = document.createElement('style');
|
12
|
+
style.type = 'text/css';
|
13
|
+
style.innerHTML = componentCss;
|
14
|
+
document.head.appendChild(style);
|
15
|
+
}
|
@@ -1,24 +1,21 @@
|
|
1
1
|
import type AMSCheckout from '../../core/instance';
|
2
|
-
import type {
|
3
|
-
import {
|
4
|
-
type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
|
2
|
+
import type { IappendIframeNodesParams, IcreateComponent } from '../../types';
|
3
|
+
import { componentNameEnum } from '../../types';
|
5
4
|
export default class ComponentApp {
|
6
5
|
app: any;
|
6
|
+
appDomain: string;
|
7
7
|
AMSSDK: AMSCheckout;
|
8
|
-
platform:
|
9
|
-
_performanceData: any[];
|
10
|
-
_loadAppPromiseResolve: ((value: Boolean) => void) | null;
|
11
|
-
_isInitComponent: boolean;
|
12
|
-
private appDomain;
|
8
|
+
platform: 'desktop' | 'mobile';
|
13
9
|
private createIframeNode;
|
14
10
|
private _selector;
|
15
11
|
private _appVersion;
|
16
12
|
private _isRetention;
|
17
13
|
private _actionQueryPromise;
|
18
14
|
private _renderParams;
|
19
|
-
private
|
15
|
+
private _componentName;
|
16
|
+
private _performanceData;
|
17
|
+
private _isInitComponent;
|
20
18
|
private _clickEventName;
|
21
|
-
private _renderDisplayType;
|
22
19
|
constructor();
|
23
20
|
/**
|
24
21
|
* @description Cancel listening and destroy the dom
|
@@ -31,19 +28,16 @@ export default class ComponentApp {
|
|
31
28
|
/**
|
32
29
|
* @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
|
33
30
|
*/
|
34
|
-
setRender(
|
31
|
+
setRender(createIframeNode: (context: ComponentApp, params: IcreateComponent) => Promise<void>): void;
|
35
32
|
/**
|
36
33
|
* @description render iframe content
|
37
34
|
*/
|
38
|
-
appendIframeNodes(
|
39
|
-
private renderInlineLoading;
|
40
|
-
private renderPopupLoading;
|
41
|
-
_createLoadAppPromise(): Promise<unknown>;
|
35
|
+
appendIframeNodes(componentName: componentNameEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, any]>;
|
42
36
|
/**
|
43
37
|
* @description Interface request
|
44
38
|
*/
|
45
39
|
private createActionQueryPromise;
|
46
|
-
private
|
40
|
+
private cleanApp;
|
47
41
|
/**
|
48
42
|
* @description Create app
|
49
43
|
*/
|
@@ -53,12 +47,12 @@ export default class ComponentApp {
|
|
53
47
|
/**
|
54
48
|
* @description Initialize subscription iframe message
|
55
49
|
*/
|
56
|
-
private
|
57
|
-
private
|
50
|
+
private _addEventListener;
|
51
|
+
private _removeEventListener;
|
58
52
|
/**
|
59
53
|
* @description Processing messages from iframe
|
60
54
|
*/
|
61
|
-
_handleAppMessage
|
55
|
+
private _handleAppMessage;
|
62
56
|
private handleSizeChanged;
|
63
57
|
private handleRedirect;
|
64
58
|
private handleDeclareInfo;
|
@@ -66,16 +60,11 @@ export default class ComponentApp {
|
|
66
60
|
/**
|
67
61
|
* @description Send message to SDK
|
68
62
|
*/
|
69
|
-
dispatchToSDK
|
63
|
+
private dispatchToSDK;
|
70
64
|
/**
|
71
65
|
* @description Send message to iframe
|
72
66
|
*/
|
73
|
-
dispatchToApp
|
74
|
-
context: {
|
75
|
-
event: string;
|
76
|
-
data: any;
|
77
|
-
};
|
78
|
-
}): any;
|
67
|
+
private dispatchToApp;
|
79
68
|
/**
|
80
69
|
* @description Subscribe to messages from SDK
|
81
70
|
*/
|
@@ -84,16 +73,30 @@ export default class ComponentApp {
|
|
84
73
|
* @description Send rendering events to iframe
|
85
74
|
*/
|
86
75
|
private sendRenderEvent;
|
76
|
+
private showLoading;
|
77
|
+
/**
|
78
|
+
* @description show cashier
|
79
|
+
*/
|
80
|
+
private showCashier;
|
87
81
|
/**
|
88
82
|
* @description close cashier
|
89
83
|
*/
|
90
|
-
private
|
91
|
-
private
|
84
|
+
private closeCashier;
|
85
|
+
private hideComponentAndCleanDom;
|
92
86
|
private closeBtnFunc;
|
87
|
+
/**
|
88
|
+
* @description create mount node
|
89
|
+
*/
|
90
|
+
private createMountElement;
|
91
|
+
private createCloseBtn;
|
92
|
+
private createRetentionPopup;
|
93
93
|
private retentionPopupLeaveFunc;
|
94
94
|
private removeRetentionPopup;
|
95
95
|
private showRetentionPopup;
|
96
|
-
private
|
96
|
+
private hideRetentionPopup;
|
97
|
+
/**
|
98
|
+
* @description create mockup
|
99
|
+
*/
|
100
|
+
private createMockup;
|
97
101
|
private submitForm;
|
98
102
|
}
|
99
|
-
export {};
|