@alipay/ams-checkout 0.0.1694400497-dev.1 → 1.3.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/{esm/config/request.d.ts → dist/esm/config/index.d.ts} +1 -0
- package/{esm/config/request.js → dist/esm/config/index.js} +3 -1
- package/{esm → dist/esm}/constant/index.d.ts +32 -54
- package/{esm → dist/esm}/constant/index.js +32 -54
- package/dist/esm/core/component/index.d.ts +17 -0
- package/dist/esm/core/component/index.js +146 -0
- package/dist/esm/core/drop-in/index.d.ts +29 -0
- package/{esm → dist/esm}/core/drop-in/index.js +19 -19
- package/{esm → dist/esm}/core/instance/index.d.ts +23 -6
- package/{esm → dist/esm}/core/instance/index.js +75 -32
- package/{esm/config/index.js → dist/esm/index.d.ts} +15 -10
- package/{esm → dist/esm}/index.js +30 -8
- package/dist/esm/plugin/component/appPath.d.ts +2 -0
- package/dist/esm/plugin/component/appPath.js +75 -0
- package/{esm/plugin/component/component.inline.style.d.ts → dist/esm/plugin/component/component.style.d.ts} +1 -4
- package/dist/esm/plugin/component/component.style.js +15 -0
- package/{esm → dist/esm}/plugin/component/index.d.ts +45 -33
- package/{esm → dist/esm}/plugin/component/index.js +450 -316
- package/{esm → dist/esm}/plugin/drop-in/index.d.ts +9 -7
- package/{esm → dist/esm}/plugin/drop-in/index.js +3 -4
- package/{esm → dist/esm/request}/index.d.ts +8 -9
- package/{esm → dist/esm}/request/index.js +13 -11
- package/{esm → dist/esm}/request/utils.d.ts +3 -3
- package/{esm → dist/esm}/request/utils.js +4 -6
- package/dist/esm/service/index.d.ts +2 -0
- package/{esm → dist/esm}/types/index.d.ts +48 -116
- package/dist/esm/types/index.js +94 -0
- package/dist/esm/util/createIframeNode.d.ts +5 -0
- package/dist/esm/util/createIframeNode.js +35 -0
- package/{esm → dist/esm}/util/get.js +0 -7
- package/{esm → dist/esm}/util/index.d.ts +4 -6
- package/{esm → dist/esm}/util/index.js +13 -29
- package/dist/esm/util/mock.js +4 -0
- package/dist/umd/ams-checkout.min.js +1 -1
- package/package.json +1 -1
- package/esm/config/index.d.ts +0 -2
- package/esm/core/component/index.d.ts +0 -24
- package/esm/core/component/index.js +0 -211
- package/esm/core/drop-in/index.d.ts +0 -22
- package/esm/image/skeleton.svg +0 -18
- package/esm/plugin/component/cashierApp.d.ts +0 -23
- package/esm/plugin/component/cashierApp.js +0 -123
- 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 -165
- package/esm/request/index.d.ts +0 -8
- package/esm/service/index.d.ts +0 -2
- package/esm/types/index.js +0 -134
- package/esm/util/createIframeNode.d.ts +0 -5
- package/esm/util/createIframeNode.js +0 -42
- package/esm/util/mock.js +0 -3
- /package/{esm → dist/esm}/image/cta.svg +0 -0
- /package/{esm → dist/esm}/service/index.js +0 -0
- /package/{esm → dist/esm}/util/get.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/browser.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/browser.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/evoke.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/evoke.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/generate.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/generate.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/index.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/index.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/main.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/main.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/openWallet.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/openWallet.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/types.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/types.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/utils/config.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/utils/config.js +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/utils/index.d.ts +0 -0
- /package/{esm → dist/esm}/util/intl-callapp/es/utils/index.js +0 -0
- /package/{esm → dist/esm}/util/mock.d.ts +0 -0
@@ -1,16 +1,16 @@
|
|
1
|
-
import type { AMSCheckoutOptions,
|
1
|
+
import type { AMSCheckoutOptions, callOnError, callOnSizeChanged, checkoutState, optionsParams } from '../../types/index';
|
2
2
|
import { EventCenter } from '../../util/index';
|
3
3
|
export default class AMSSDK {
|
4
4
|
options: AMSCheckoutOptions;
|
5
|
-
checkoutState:
|
6
|
-
|
5
|
+
checkoutState: checkoutState;
|
6
|
+
eventCenter: EventCenter;
|
7
7
|
protected plugins: Map<string, any>;
|
8
8
|
_instanceId: string;
|
9
|
-
constructor(options:
|
9
|
+
constructor(options: optionsParams);
|
10
10
|
/**
|
11
11
|
* @description Destroy and process some contents of the plug-in
|
12
12
|
*/
|
13
|
-
|
13
|
+
destroy(): void;
|
14
14
|
/**
|
15
15
|
* @description Set the sdk basic configuration
|
16
16
|
*/
|
@@ -34,7 +34,7 @@ export default class AMSSDK {
|
|
34
34
|
/**
|
35
35
|
* @description Get Plug-in
|
36
36
|
*/
|
37
|
-
|
37
|
+
_getPlugin(pluginId: string): any;
|
38
38
|
/**
|
39
39
|
* @description Execute to open app or jump link
|
40
40
|
*/
|
@@ -47,4 +47,21 @@ export default class AMSSDK {
|
|
47
47
|
* @description Overlay Subscription
|
48
48
|
*/
|
49
49
|
protected _overrideSubscription(name: string, func: any, funcKey: string): void;
|
50
|
+
/**
|
51
|
+
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
52
|
+
*/
|
53
|
+
onError(event: callOnError): void;
|
54
|
+
/**
|
55
|
+
* @description Create an event handler, called when the checkout view is available for interaction.
|
56
|
+
* mode: dropin
|
57
|
+
*/
|
58
|
+
/**
|
59
|
+
* @description Create an event handler, called after the user selects the payment method
|
60
|
+
* mode: dropin
|
61
|
+
*/
|
62
|
+
/**
|
63
|
+
* @description Create an event handler
|
64
|
+
*/
|
65
|
+
onSizeChanged(event: callOnSizeChanged): void;
|
66
|
+
onLog(event: callOnSizeChanged): void;
|
50
67
|
}
|
@@ -15,10 +15,9 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
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
|
16
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.
|
17
17
|
*/
|
18
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
19
18
|
import { v4 as uuid } from 'uuid';
|
20
19
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
21
|
-
import {
|
20
|
+
import { environment, mode, networkMode, osType, terminalType } from "../../types/index";
|
22
21
|
import { device, EventCenter, getType, queryParse } from "../../util/index";
|
23
22
|
import CallApp from "../../util/intl-callapp/es/main";
|
24
23
|
var AMSSDK = /*#__PURE__*/function () {
|
@@ -26,13 +25,16 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
26
25
|
_classCallCheck(this, AMSSDK);
|
27
26
|
_defineProperty(this, "options", void 0);
|
28
27
|
_defineProperty(this, "checkoutState", void 0);
|
29
|
-
_defineProperty(this, "
|
28
|
+
_defineProperty(this, "eventCenter", void 0);
|
30
29
|
_defineProperty(this, "plugins", void 0);
|
31
30
|
_defineProperty(this, "_instanceId", void 0);
|
32
31
|
this._instanceId = uuid();
|
33
32
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
34
33
|
this.options = {};
|
35
|
-
this.
|
34
|
+
this.eventCenter = new EventCenter();
|
35
|
+
this.checkoutState = {
|
36
|
+
paymentMethodType: ''
|
37
|
+
};
|
36
38
|
this._initEvent(options);
|
37
39
|
this._setOptions(options);
|
38
40
|
this.plugins = new Map();
|
@@ -41,8 +43,8 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
41
43
|
* @description Destroy and process some contents of the plug-in
|
42
44
|
*/
|
43
45
|
_createClass(AMSSDK, [{
|
44
|
-
key: "
|
45
|
-
value: function
|
46
|
+
key: "destroy",
|
47
|
+
value: function destroy() {
|
46
48
|
var _iterator = _createForOfIteratorHelper(this.plugins.values()),
|
47
49
|
_step;
|
48
50
|
try {
|
@@ -51,9 +53,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
51
53
|
try {
|
52
54
|
plugin.logoutPlugin();
|
53
55
|
// eslint-disable-next-line no-empty
|
54
|
-
} catch (error) {
|
55
|
-
console.error(error);
|
56
|
-
}
|
56
|
+
} catch (error) {}
|
57
57
|
}
|
58
58
|
} catch (err) {
|
59
59
|
_iterator.e(err);
|
@@ -79,17 +79,17 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
79
79
|
value: function _setEnv(options) {
|
80
80
|
var _queryParse = queryParse(),
|
81
81
|
_moreEnv = _queryParse._moreEnv;
|
82
|
-
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in
|
83
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.
|
82
|
+
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environment) && _moreEnv !== 'true') {
|
83
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.errorMessage);
|
84
84
|
options.environment = 'prod';
|
85
85
|
}
|
86
86
|
this.options.env = {
|
87
|
-
terminalType: device.isMobile ?
|
87
|
+
terminalType: device.isMobile ? terminalType.WAP : terminalType.WEB,
|
88
88
|
environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
|
89
89
|
};
|
90
|
-
if (this.options.env.terminalType ===
|
90
|
+
if (this.options.env.terminalType === terminalType.WAP) {
|
91
91
|
// eslint-disable-next-line no-nested-ternary
|
92
|
-
this.options.env.osType = device.iOS ?
|
92
|
+
this.options.env.osType = device.iOS ? osType.IOS : device.Android ? osType.ANDROID : osType.ELSE;
|
93
93
|
}
|
94
94
|
}
|
95
95
|
/**
|
@@ -98,15 +98,15 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
98
98
|
}, {
|
99
99
|
key: "_setMode",
|
100
100
|
value: function _setMode(options) {
|
101
|
-
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) ||
|
102
|
-
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in
|
103
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.
|
104
|
-
this.options.mode =
|
101
|
+
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || mode.dropin;
|
102
|
+
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in mode)) {
|
103
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.errorMessage);
|
104
|
+
this.options.mode = mode.component;
|
105
105
|
}
|
106
|
-
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) ||
|
107
|
-
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in
|
108
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.
|
109
|
-
this.options.networkMode =
|
106
|
+
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkMode.session;
|
107
|
+
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkMode)) {
|
108
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
|
109
|
+
this.options.networkMode = networkMode.proxy;
|
110
110
|
}
|
111
111
|
}
|
112
112
|
/**
|
@@ -116,28 +116,32 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
116
116
|
key: "_initEvent",
|
117
117
|
value: function _initEvent(options) {
|
118
118
|
if (options !== null && options !== void 0 && options.onError) {
|
119
|
-
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
119
|
+
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
120
120
|
this._overrideSubscription(EVENT.error.name, options.onError, EVENT.error.uniqueKey);
|
121
121
|
}
|
122
122
|
if (options !== null && options !== void 0 && options.onPaymentMethodSelected) {
|
123
|
-
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
123
|
+
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
124
124
|
this._overrideSubscription(EVENT.paymentMethodSelected.name, options.onPaymentMethodSelected, EVENT.paymentMethodSelected.uniqueKey);
|
125
125
|
}
|
126
|
+
if (options !== null && options !== void 0 && options.onReady) {
|
127
|
+
if (getType(options.onReady) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
128
|
+
this._overrideSubscription(EVENT.ready.name, options.onReady, EVENT.ready.uniqueKey);
|
129
|
+
}
|
126
130
|
if (options !== null && options !== void 0 && options.onSizeChanged) {
|
127
|
-
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
131
|
+
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
128
132
|
this._overrideSubscription(EVENT.sizeChanged.name, options.onSizeChanged, EVENT.sizeChanged.uniqueKey);
|
129
133
|
}
|
130
134
|
if (options !== null && options !== void 0 && options.onLog) {
|
131
|
-
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
135
|
+
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
132
136
|
this._overrideSubscription(EVENT.log.name, options.onLog, EVENT.log.uniqueKey);
|
133
137
|
}
|
134
138
|
if (options !== null && options !== void 0 && options.onEventCallback) {
|
135
|
-
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
139
|
+
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
136
140
|
this._overrideSubscription(EVENT.eventCallback.name, options.onEventCallback, EVENT.eventCallback.uniqueKey);
|
137
141
|
}
|
138
142
|
if (options !== null && options !== void 0 && options.onClose) {
|
139
|
-
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
140
|
-
this._overrideSubscription(EVENT.
|
143
|
+
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
|
144
|
+
this._overrideSubscription(EVENT.onClose.name, options.onClose, EVENT.onClose.uniqueKey);
|
141
145
|
}
|
142
146
|
}
|
143
147
|
/**
|
@@ -175,7 +179,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
175
179
|
value: function _redirect(data) {
|
176
180
|
var _this = this;
|
177
181
|
return new Promise(function (resolve, reject) {
|
178
|
-
var isWeb = _this.options.env.terminalType ===
|
182
|
+
var isWeb = _this.options.env.terminalType === terminalType.WEB;
|
179
183
|
var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
|
180
184
|
var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
|
181
185
|
var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
|
@@ -224,8 +228,47 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
224
228
|
}, {
|
225
229
|
key: "_overrideSubscription",
|
226
230
|
value: function _overrideSubscription(name, func, funcKey) {
|
227
|
-
this.
|
228
|
-
this.
|
231
|
+
this.eventCenter.off(name, func, funcKey);
|
232
|
+
this.eventCenter.on(name, func, funcKey);
|
233
|
+
}
|
234
|
+
/**
|
235
|
+
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
236
|
+
*/
|
237
|
+
}, {
|
238
|
+
key: "onError",
|
239
|
+
value: function onError(event) {
|
240
|
+
this._overrideSubscription(EVENT.error.name, event, EVENT.error.uniqueKey);
|
241
|
+
}
|
242
|
+
/**
|
243
|
+
* @description Create an event handler, called when the checkout view is available for interaction.
|
244
|
+
* mode: dropin
|
245
|
+
*/
|
246
|
+
// onReady(event: () => void) {
|
247
|
+
// this._overrideSubscription(EVENT.ready.name, event, EVENT.ready.uniqueKey);
|
248
|
+
// }
|
249
|
+
/**
|
250
|
+
* @description Create an event handler, called after the user selects the payment method
|
251
|
+
* mode: dropin
|
252
|
+
*/
|
253
|
+
// onPaymentMethodSelected(event: callonPaymentMethodSelected) {
|
254
|
+
// this._overrideSubscription(
|
255
|
+
// EVENT.paymentMethodSelected.name,
|
256
|
+
// event,
|
257
|
+
// EVENT.paymentMethodSelected.uniqueKey,
|
258
|
+
// );
|
259
|
+
// }
|
260
|
+
/**
|
261
|
+
* @description Create an event handler
|
262
|
+
*/
|
263
|
+
}, {
|
264
|
+
key: "onSizeChanged",
|
265
|
+
value: function onSizeChanged(event) {
|
266
|
+
this._overrideSubscription(EVENT.sizeChanged.name, event, EVENT.sizeChanged.uniqueKey);
|
267
|
+
}
|
268
|
+
}, {
|
269
|
+
key: "onLog",
|
270
|
+
value: function onLog(event) {
|
271
|
+
this._overrideSubscription(EVENT.log.name, event, EVENT.log.uniqueKey);
|
229
272
|
}
|
230
273
|
}]);
|
231
274
|
return AMSSDK;
|
@@ -5,13 +5,18 @@
|
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
import { IcreateComponentFunc } from './core/component/index';
|
9
|
+
import { IconfirmPaymentFunc, IcreatePaymentFunc } from './core/drop-in/index';
|
10
|
+
import AMSSDK from './core/instance';
|
11
|
+
import { optionsParams } from './types';
|
12
|
+
export * from './types';
|
13
|
+
export declare class AMSCheckout extends AMSSDK {
|
14
|
+
createComponent: IcreateComponentFunc;
|
15
|
+
createPayment: IcreatePaymentFunc;
|
16
|
+
confirmPayment: IconfirmPaymentFunc;
|
17
|
+
constructor(options: optionsParams);
|
18
|
+
}
|
19
|
+
export declare class AMSAutoDebit extends AMSCheckout {
|
20
|
+
constructor(options: optionsParams);
|
21
|
+
}
|
22
|
+
export default AMSCheckout;
|
@@ -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);
|
@@ -0,0 +1,2 @@
|
|
1
|
+
export declare const getAppPath: (_environment: string | undefined, appVersion: string, componentName: string, productSceneVersion: string, extendInfo: string) => any;
|
2
|
+
export declare const getAppDomain: (_environment: string, version: string, componentName: string, productSceneVersion: string, extendInfo: string) => string;
|
@@ -0,0 +1,75 @@
|
|
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
|
+
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
4
|
+
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); }
|
5
|
+
/**
|
6
|
+
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
7
|
+
*
|
8
|
+
* 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:
|
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
|
+
* 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
|
+
*/
|
12
|
+
import json from "../../../package.json";
|
13
|
+
import { componentNameEnum } from "../../types";
|
14
|
+
import { queryParse } from "../../util/index";
|
15
|
+
export var getAppPath = function getAppPath() {
|
16
|
+
var _componentMap;
|
17
|
+
var _environment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'prod';
|
18
|
+
var appVersion = arguments.length > 1 ? arguments[1] : undefined;
|
19
|
+
var componentName = arguments.length > 2 ? arguments[2] : undefined;
|
20
|
+
var productSceneVersion = arguments.length > 3 ? arguments[3] : undefined;
|
21
|
+
var extendInfo = arguments.length > 4 ? arguments[4] : undefined;
|
22
|
+
var _ref = queryParse() || {},
|
23
|
+
urlTestHost = _ref.host,
|
24
|
+
_ref$_appVersion = _ref._appVersion,
|
25
|
+
_appVersion = _ref$_appVersion === void 0 ? '' : _ref$_appVersion;
|
26
|
+
var host = '';
|
27
|
+
var getAppVersion = function getAppVersion(_extendInfo) {
|
28
|
+
try {
|
29
|
+
// Configure the specified version number
|
30
|
+
if (_appVersion && !['sandbox', 'light_sandbox', 'prod'].includes(_environment)) return _appVersion;
|
31
|
+
var info = JSON.parse(_extendInfo);
|
32
|
+
return info.versionMap.web[json.version].targetWebVerison || appVersion;
|
33
|
+
} catch (error) {
|
34
|
+
return appVersion;
|
35
|
+
}
|
36
|
+
};
|
37
|
+
var marmptMap = {
|
38
|
+
dev: 'http://page.alipay.net/page/antom-web-checkout/src/component-app',
|
39
|
+
sit: 'http://page.test.alipay.net/page/antom-web-checkout/src/component-app',
|
40
|
+
pre: 'https://pre.ac.alipay.com/page/antom-web-checkout/src/component-app',
|
41
|
+
sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
42
|
+
light_sandbox: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app',
|
43
|
+
prod: 'https://ac.alipay.com/page/antom-web-checkout/src/component-app'
|
44
|
+
};
|
45
|
+
var finalAppVersion = getAppVersion(extendInfo);
|
46
|
+
var getFinalProductSceneVersion = function getFinalProductSceneVersion(supportProductSceneVersion) {
|
47
|
+
// 从左到右,从旧到新
|
48
|
+
var isSupport = supportProductSceneVersion.find(function (it) {
|
49
|
+
return it === productSceneVersion;
|
50
|
+
});
|
51
|
+
var finalProductSceneVersion = supportProductSceneVersion[supportProductSceneVersion.length - 1];
|
52
|
+
if (isSupport) finalProductSceneVersion = productSceneVersion;
|
53
|
+
return finalProductSceneVersion;
|
54
|
+
};
|
55
|
+
var componentMap = (_componentMap = {}, _defineProperty(_componentMap, componentNameEnum.card, function () {
|
56
|
+
host = "".concat(marmptMap[_environment], "/").concat(componentNameEnum.card, "/index.").concat(finalAppVersion, ".html");
|
57
|
+
}), _defineProperty(_componentMap, componentNameEnum.easyPay, function () {
|
58
|
+
var finalProductSceneVersion = getFinalProductSceneVersion(['1.0', '2.0']);
|
59
|
+
host = "".concat(marmptMap[_environment], "/").concat(componentNameEnum.easyPay, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
60
|
+
}), _defineProperty(_componentMap, componentNameEnum.autoDebit, function () {
|
61
|
+
var finalProductSceneVersion = getFinalProductSceneVersion(['1.0']);
|
62
|
+
host = "".concat(marmptMap[_environment], "/").concat(componentNameEnum.autoDebit, "/").concat(finalProductSceneVersion, "/index.").concat(finalAppVersion, ".html");
|
63
|
+
}), _componentMap);
|
64
|
+
if (componentMap[componentName]) componentMap[componentName]();
|
65
|
+
// only for test while testurl?host=https://xxxxx.test.html
|
66
|
+
if (urlTestHost && !['sandbox', 'light_sandbox', 'prod'].includes(_environment)) {
|
67
|
+
return urlTestHost;
|
68
|
+
}
|
69
|
+
return host;
|
70
|
+
};
|
71
|
+
export var getAppDomain = function getAppDomain(_environment, version, componentName, productSceneVersion, extendInfo) {
|
72
|
+
var reg = /^https?:\/\/([^/<>\s]+\.?)*/;
|
73
|
+
var macth = reg.exec(getAppPath(_environment, version, componentName, productSceneVersion, extendInfo));
|
74
|
+
return macth && macth[0] || '';
|
75
|
+
};
|
@@ -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 background-color: #ffffff;\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 background-color: #ffffff;\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 background-color: #ffffff;\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,22 @@
|
|
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
|
+
paymentMethodsResult: any;
|
7
|
+
appDomain: string;
|
7
8
|
AMSSDK: AMSCheckout;
|
8
|
-
platform:
|
9
|
-
_performanceData: any[];
|
10
|
-
_loadAppPromiseResolve: ((value: boolean) => void) | null;
|
11
|
-
_isInitComponent: boolean;
|
12
|
-
private appDomain;
|
9
|
+
platform: 'desktop' | 'mobile';
|
13
10
|
private createIframeNode;
|
14
11
|
private _selector;
|
15
12
|
private _appVersion;
|
16
13
|
private _isRetention;
|
17
14
|
private _actionQueryPromise;
|
18
15
|
private _renderParams;
|
19
|
-
private
|
16
|
+
private _componentName;
|
17
|
+
private _performanceData;
|
18
|
+
private _isInitComponent;
|
20
19
|
private _clickEventName;
|
21
|
-
private _renderDisplayType;
|
22
20
|
constructor();
|
23
21
|
/**
|
24
22
|
* @description Cancel listening and destroy the dom
|
@@ -31,34 +29,36 @@ export default class ComponentApp {
|
|
31
29
|
/**
|
32
30
|
* @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
31
|
*/
|
34
|
-
setRender(
|
32
|
+
setRender(createIframeNode: (context: ComponentApp, params: IcreateComponent) => Promise<void>): void;
|
35
33
|
/**
|
36
34
|
* @description render iframe content
|
37
35
|
*/
|
38
|
-
appendIframeNodes(
|
39
|
-
private
|
40
|
-
private
|
41
|
-
_createLoadAppPromise(): Promise<unknown>;
|
42
|
-
/**
|
43
|
-
* @description Interface request
|
44
|
-
*/
|
45
|
-
private createActionQueryPromise;
|
46
|
-
private cleanElement;
|
36
|
+
appendIframeNodes(componentName: componentNameEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, any]>;
|
37
|
+
private newQueryPromise;
|
38
|
+
private cleanApp;
|
47
39
|
/**
|
48
40
|
* @description Create app
|
49
41
|
*/
|
50
42
|
private createApp;
|
51
|
-
private
|
52
|
-
|
43
|
+
private getIframeUrl;
|
44
|
+
/**
|
45
|
+
* @description Create iframe
|
46
|
+
*/
|
47
|
+
private createIframe;
|
48
|
+
/**
|
49
|
+
* @description Get iftame id
|
50
|
+
*/
|
51
|
+
private _getIframeId;
|
52
|
+
private _listener;
|
53
53
|
/**
|
54
54
|
* @description Initialize subscription iframe message
|
55
55
|
*/
|
56
|
-
private
|
57
|
-
private
|
56
|
+
private _addEventListener;
|
57
|
+
private _removeEventListener;
|
58
58
|
/**
|
59
59
|
* @description Processing messages from iframe
|
60
60
|
*/
|
61
|
-
_handleAppMessage
|
61
|
+
private _handleAppMessage;
|
62
62
|
private handleSizeChanged;
|
63
63
|
private handleRedirect;
|
64
64
|
private handleDeclareInfo;
|
@@ -66,13 +66,11 @@ export default class ComponentApp {
|
|
66
66
|
/**
|
67
67
|
* @description Send message to SDK
|
68
68
|
*/
|
69
|
-
dispatchToSDK
|
69
|
+
private dispatchToSDK;
|
70
70
|
/**
|
71
71
|
* @description Send message to iframe
|
72
72
|
*/
|
73
|
-
dispatchToApp
|
74
|
-
context: eventPayloadContext;
|
75
|
-
}): any;
|
73
|
+
private dispatchToApp;
|
76
74
|
/**
|
77
75
|
* @description Subscribe to messages from SDK
|
78
76
|
*/
|
@@ -81,16 +79,30 @@ export default class ComponentApp {
|
|
81
79
|
* @description Send rendering events to iframe
|
82
80
|
*/
|
83
81
|
private sendRenderEvent;
|
82
|
+
private showLoading;
|
83
|
+
/**
|
84
|
+
* @description show cashier
|
85
|
+
*/
|
86
|
+
private showCashier;
|
84
87
|
/**
|
85
88
|
* @description close cashier
|
86
89
|
*/
|
87
|
-
private
|
88
|
-
private
|
90
|
+
private closeCashier;
|
91
|
+
private hideComponentAndCleanDom;
|
89
92
|
private closeBtnFunc;
|
93
|
+
/**
|
94
|
+
* @description create mount node
|
95
|
+
*/
|
96
|
+
private createMountElement;
|
97
|
+
private createCloseBtn;
|
98
|
+
private createRetentionPopup;
|
90
99
|
private retentionPopupLeaveFunc;
|
91
100
|
private removeRetentionPopup;
|
92
101
|
private showRetentionPopup;
|
93
|
-
private
|
102
|
+
private hideRetentionPopup;
|
103
|
+
/**
|
104
|
+
* @description create mockup
|
105
|
+
*/
|
106
|
+
private createMockup;
|
94
107
|
private submitForm;
|
95
108
|
}
|
96
|
-
export {};
|