@alipay/ams-checkout 0.0.1691379784-dev.6 → 0.0.1691743027-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/constant/index.d.ts +40 -32
- package/esm/constant/index.js +40 -32
- package/esm/core/component/index.d.ts +22 -9
- package/esm/core/component/index.js +148 -43
- package/esm/core/drop-in/index.d.ts +1 -1
- package/esm/core/instance/index.d.ts +6 -15
- package/esm/core/instance/index.js +31 -53
- package/esm/image/skeleton.svg +18 -0
- package/esm/index.d.ts +4 -10
- package/esm/index.js +8 -30
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +15 -15
- package/esm/plugin/component/component.style.d.ts +4 -1
- package/esm/plugin/component/component.style.js +33 -4
- package/esm/plugin/component/index.d.ts +15 -9
- package/esm/plugin/component/index.js +199 -156
- package/esm/plugin/drop-in/index.js +1 -1
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +3 -3
- 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 +61 -34
- package/esm/types/index.js +73 -47
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +6 -4
- package/esm/util/index.js +24 -9
- package/esm/util/mock.js +1 -2
- package/package.json +1 -1
package/esm/request/index.d.ts
CHANGED
@@ -5,11 +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 {
|
8
|
+
import { IrequestConfig } from '../types';
|
9
9
|
/**
|
10
10
|
*
|
11
11
|
* @param requestData 请求参数
|
12
12
|
* @param options 请求配置
|
13
13
|
* @example request({ name: 'test' }, { operation-type: 'xxx.xxx.xxx' })
|
14
14
|
*/
|
15
|
-
export declare function request<T>(requestData: Record<string, any> | undefined, options:
|
15
|
+
export declare function request<T>(requestData: Record<string, any> | undefined, options: IrequestConfig): Promise<T>;
|
package/esm/request/index.js
CHANGED
@@ -17,7 +17,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
|
18
18
|
import { sdkVersion } from "../config/index";
|
19
19
|
import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
|
20
|
-
import {
|
20
|
+
import { errorEnum } from "../types";
|
21
21
|
import { get } from "../util/get";
|
22
22
|
import axios from 'axios';
|
23
23
|
import { device, fomatGetwayError, isPC, queryParse, safeJson } from "../util";
|
@@ -125,10 +125,10 @@ function _request() {
|
|
125
125
|
console.log('request error', _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message);
|
126
126
|
_error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
|
127
127
|
success: false,
|
128
|
-
errorCode:
|
128
|
+
errorCode: errorEnum.SYSTEM,
|
129
129
|
errorMessage: ''
|
130
130
|
});
|
131
|
-
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ?
|
131
|
+
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
|
132
132
|
errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
|
133
133
|
return _context.abrupt("return", Promise.reject({
|
134
134
|
success: false,
|
package/esm/request/utils.d.ts
CHANGED
@@ -5,19 +5,19 @@
|
|
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 {
|
8
|
+
import { errorEnum } from '../types';
|
9
9
|
export declare const safeJson: (data: any, obj: any) => any;
|
10
10
|
export declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {
|
11
11
|
success: boolean;
|
12
12
|
traceId: string;
|
13
|
-
errorCode:
|
13
|
+
errorCode: errorEnum;
|
14
14
|
resultStatus: any;
|
15
15
|
errorMessage?: undefined;
|
16
16
|
result?: undefined;
|
17
17
|
} | {
|
18
18
|
success: boolean;
|
19
19
|
traceId: string;
|
20
|
-
errorCode:
|
20
|
+
errorCode: errorEnum;
|
21
21
|
errorMessage: string;
|
22
22
|
result: {
|
23
23
|
resultStatus: any;
|
package/esm/request/utils.js
CHANGED
@@ -6,7 +6,7 @@
|
|
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
8
|
|
9
|
-
import {
|
9
|
+
import { errorEnum } from "../types";
|
10
10
|
import { get } from "../util/get";
|
11
11
|
export var safeJson = function safeJson(data, obj) {
|
12
12
|
try {
|
@@ -26,7 +26,7 @@ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
|
26
26
|
return {
|
27
27
|
success: false,
|
28
28
|
traceId: traceId,
|
29
|
-
errorCode:
|
29
|
+
errorCode: errorEnum.LOGIN,
|
30
30
|
resultStatus: resultStatus
|
31
31
|
};
|
32
32
|
}
|
@@ -35,7 +35,7 @@ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
|
35
35
|
return {
|
36
36
|
success: false,
|
37
37
|
traceId: traceId,
|
38
|
-
errorCode:
|
38
|
+
errorCode: errorEnum.TIMEOUT,
|
39
39
|
resultStatus: resultStatus
|
40
40
|
};
|
41
41
|
}
|
@@ -45,7 +45,7 @@ export var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
|
45
45
|
return {
|
46
46
|
success: false,
|
47
47
|
traceId: traceId,
|
48
|
-
errorCode:
|
48
|
+
errorCode: errorEnum.GATEWAY,
|
49
49
|
errorMessage: decodeURIComponent(tips || ''),
|
50
50
|
result: {
|
51
51
|
resultStatus: resultStatus || '',
|
package/esm/service/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult,
|
2
|
-
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?:
|
1
|
+
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
|
2
|
+
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: IrequestConfig): Promise<CashierSdkActionQueryResult>;
|
package/esm/types/index.d.ts
CHANGED
@@ -8,27 +8,32 @@
|
|
8
8
|
/**
|
9
9
|
* SDK options
|
10
10
|
*/
|
11
|
-
export interface
|
11
|
+
export interface IoptionsParams {
|
12
12
|
environment?: string;
|
13
13
|
locale?: string;
|
14
14
|
onError?: callOnError;
|
15
15
|
onSizeChanged?: callOnSizeChanged;
|
16
16
|
onPaymentMethodSelected?: callonPaymentMethodSelected;
|
17
17
|
onLog?: callOnLog;
|
18
|
-
onEventCallback?:
|
19
|
-
onClose?:
|
18
|
+
onEventCallback?: callOnEventCallback;
|
19
|
+
onClose?: callOnClose;
|
20
20
|
networkMode?: string;
|
21
21
|
mode?: string;
|
22
22
|
analytics?: {
|
23
23
|
enabled: boolean;
|
24
24
|
};
|
25
25
|
}
|
26
|
-
export
|
26
|
+
export type Iselector = string;
|
27
|
+
export declare enum renderDisplayTypeEnum {
|
28
|
+
'popup' = "popup",
|
29
|
+
'inline' = "inline"
|
30
|
+
}
|
31
|
+
export interface IcreatePaymentParams {
|
27
32
|
paymentMethodsResult?: any;
|
28
33
|
paymentSessionData?: string;
|
29
|
-
selector:
|
34
|
+
selector: Iselector;
|
30
35
|
appearance?: {
|
31
|
-
displayType?:
|
36
|
+
displayType?: checkoutDisplayEnum;
|
32
37
|
backgroundColor?: string;
|
33
38
|
};
|
34
39
|
}
|
@@ -51,11 +56,12 @@ export declare enum paymentMethodCategoryTypeEnum {
|
|
51
56
|
}
|
52
57
|
export interface IcreateComponent {
|
53
58
|
paymentSessionData: string;
|
54
|
-
selector?: string | HTMLElement;
|
55
59
|
appearance?: Record<string, any>;
|
56
60
|
}
|
57
61
|
export interface IappendIframeNodesParams extends IcreateComponent {
|
58
|
-
paymentSessionMetaData
|
62
|
+
paymentSessionMetaData: IpaymentSessionMetaData;
|
63
|
+
renderDisplayType: renderDisplayTypeEnum;
|
64
|
+
selector?: Iselector;
|
59
65
|
}
|
60
66
|
interface IpaymentSessionConfig {
|
61
67
|
productScene: productSceneEnum;
|
@@ -74,58 +80,79 @@ export interface IpaymentSessionMetaData {
|
|
74
80
|
export declare enum localeEnum {
|
75
81
|
'en-US' = "en-US"
|
76
82
|
}
|
77
|
-
export declare enum
|
83
|
+
export declare enum checkoutDisplayEnum {
|
78
84
|
horizon = "horizon",
|
79
85
|
vertical = "vertical"
|
80
86
|
}
|
81
|
-
export declare enum
|
87
|
+
export declare enum modeEnum {
|
82
88
|
dropin = "dropin",
|
83
89
|
component = "component"
|
84
90
|
}
|
85
|
-
export declare enum
|
91
|
+
export declare enum networkModeEnum {
|
86
92
|
proxy = "proxy",
|
87
93
|
session = "session"
|
88
94
|
}
|
89
|
-
export interface
|
90
|
-
paymentMethodType
|
95
|
+
export interface IcheckoutState {
|
96
|
+
paymentMethodType?: string;
|
91
97
|
}
|
92
|
-
export declare enum
|
98
|
+
export declare enum environmentEnum {
|
93
99
|
sandbox = "sandbox",
|
94
100
|
prod = "prod",
|
95
101
|
light_sandbox = "light_sandbox"
|
96
102
|
}
|
97
|
-
export declare enum
|
103
|
+
export declare enum osTypeEnum {
|
98
104
|
IOS = "IOS",
|
99
105
|
ANDROID = "ANDROID",
|
100
106
|
ELSE = "ELSE"
|
101
107
|
}
|
102
|
-
export declare enum
|
108
|
+
export declare enum terminalTypeEnum {
|
103
109
|
WEB = "WEB",
|
104
110
|
WAP = "WAP",
|
105
111
|
APP = "APP",
|
106
112
|
MINI_APP = "MINI_APP"
|
107
113
|
}
|
108
|
-
export interface
|
109
|
-
osType?:
|
110
|
-
terminalType:
|
114
|
+
export interface Ienv {
|
115
|
+
osType?: osTypeEnum;
|
116
|
+
terminalType: terminalTypeEnum;
|
111
117
|
environment: string;
|
112
118
|
}
|
119
|
+
export declare enum platformEnum {
|
120
|
+
desktop = "desktop",
|
121
|
+
mobile = "mobile"
|
122
|
+
}
|
123
|
+
/**
|
124
|
+
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
125
|
+
*/
|
113
126
|
export type callOnError = (state: {
|
114
|
-
|
115
|
-
|
127
|
+
code: string;
|
128
|
+
message: string;
|
116
129
|
stack?: any;
|
117
130
|
}) => void;
|
131
|
+
/**
|
132
|
+
* @description Create an event handler, called when the general log triggers during the SDK runtime.
|
133
|
+
*/
|
134
|
+
export type callOnLog = (state: {
|
135
|
+
code: string;
|
136
|
+
message: string;
|
137
|
+
}) => void;
|
138
|
+
/**
|
139
|
+
* @description Create an event handler, during the running of the sdk, some events are called after execution, and the specific event code is returned.
|
140
|
+
*/
|
141
|
+
export type callOnEventCallback = (state: {
|
142
|
+
code: string;
|
143
|
+
message: string;
|
144
|
+
}) => void;
|
118
145
|
export type callonPaymentMethodSelected = (state: {
|
119
146
|
paymentMethodType: string;
|
120
147
|
}) => void;
|
121
148
|
export type callOnSizeChanged = (state: {
|
122
|
-
width:
|
123
|
-
height:
|
124
|
-
}) => void;
|
125
|
-
export type callOnLog = (state: {
|
126
|
-
code: string;
|
127
|
-
message: string;
|
149
|
+
width: number;
|
150
|
+
height: number;
|
128
151
|
}) => void;
|
152
|
+
/**
|
153
|
+
* @description Create an event handler, In pop-up layer mode, the user clicks the semi floating layer close button and is called.
|
154
|
+
*/
|
155
|
+
export type callOnClose = () => void;
|
129
156
|
export declare enum messageName {
|
130
157
|
SDK_TO_APP = "SDK_TO_APP",
|
131
158
|
APP_TO_SDK = "APP_TO_SDK",
|
@@ -142,7 +169,7 @@ export interface eventPlayload {
|
|
142
169
|
};
|
143
170
|
}
|
144
171
|
export interface AMSCheckoutOptions {
|
145
|
-
env:
|
172
|
+
env: Ienv;
|
146
173
|
locale: string;
|
147
174
|
networkMode: string;
|
148
175
|
mode: string;
|
@@ -151,7 +178,11 @@ export interface AMSCheckoutOptions {
|
|
151
178
|
export interface Ianalytics {
|
152
179
|
enabled: boolean;
|
153
180
|
}
|
154
|
-
export declare enum
|
181
|
+
export declare enum targetEnum {
|
182
|
+
BLANK = "_blank",
|
183
|
+
SELF = "_self"
|
184
|
+
}
|
185
|
+
export declare enum errorEnum {
|
155
186
|
PARAMS = "PARAMS",
|
156
187
|
TIMEOUT = "TIMEOUT",
|
157
188
|
NETWORK = "NETWORK",
|
@@ -166,7 +197,7 @@ export declare enum ERROR {
|
|
166
197
|
SIGNIN = "SIGNIN",
|
167
198
|
GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
|
168
199
|
}
|
169
|
-
export interface
|
200
|
+
export interface IrequestConfig {
|
170
201
|
env?: string;
|
171
202
|
baseURL?: string;
|
172
203
|
timeout?: number;
|
@@ -209,8 +240,4 @@ declare global {
|
|
209
240
|
[key: string]: any;
|
210
241
|
}
|
211
242
|
}
|
212
|
-
export declare enum Target {
|
213
|
-
BLANK = "_blank",
|
214
|
-
SELF = "_self"
|
215
|
-
}
|
216
243
|
export {};
|
package/esm/types/index.js
CHANGED
@@ -10,6 +10,11 @@
|
|
10
10
|
* SDK options
|
11
11
|
*/
|
12
12
|
|
13
|
+
export var renderDisplayTypeEnum = /*#__PURE__*/function (renderDisplayTypeEnum) {
|
14
|
+
renderDisplayTypeEnum["popup"] = "popup";
|
15
|
+
renderDisplayTypeEnum["inline"] = "inline";
|
16
|
+
return renderDisplayTypeEnum;
|
17
|
+
}({});
|
13
18
|
export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {
|
14
19
|
componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";
|
15
20
|
componentSignEnum["CASHIER_PAYMENT_CARD"] = "CASHIER_PAYMENT_CARD";
|
@@ -34,64 +39,85 @@ export var localeEnum = /*#__PURE__*/function (localeEnum) {
|
|
34
39
|
localeEnum["en-US"] = "en-US";
|
35
40
|
return localeEnum;
|
36
41
|
}({});
|
37
|
-
export var
|
38
|
-
|
39
|
-
|
40
|
-
return
|
42
|
+
export var checkoutDisplayEnum = /*#__PURE__*/function (checkoutDisplayEnum) {
|
43
|
+
checkoutDisplayEnum["horizon"] = "horizon";
|
44
|
+
checkoutDisplayEnum["vertical"] = "vertical";
|
45
|
+
return checkoutDisplayEnum;
|
46
|
+
}({});
|
47
|
+
export var modeEnum = /*#__PURE__*/function (modeEnum) {
|
48
|
+
modeEnum["dropin"] = "dropin";
|
49
|
+
modeEnum["component"] = "component";
|
50
|
+
return modeEnum;
|
41
51
|
}({});
|
42
|
-
export var
|
43
|
-
|
44
|
-
|
45
|
-
return
|
52
|
+
export var networkModeEnum = /*#__PURE__*/function (networkModeEnum) {
|
53
|
+
networkModeEnum["proxy"] = "proxy";
|
54
|
+
networkModeEnum["session"] = "session";
|
55
|
+
return networkModeEnum;
|
46
56
|
}({});
|
47
|
-
export var
|
48
|
-
|
49
|
-
|
50
|
-
|
57
|
+
export var environmentEnum = /*#__PURE__*/function (environmentEnum) {
|
58
|
+
environmentEnum["sandbox"] = "sandbox";
|
59
|
+
environmentEnum["prod"] = "prod";
|
60
|
+
environmentEnum["light_sandbox"] = "light_sandbox";
|
61
|
+
return environmentEnum;
|
51
62
|
}({});
|
52
|
-
export var
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
return
|
63
|
+
export var osTypeEnum = /*#__PURE__*/function (osTypeEnum) {
|
64
|
+
osTypeEnum["IOS"] = "IOS";
|
65
|
+
osTypeEnum["ANDROID"] = "ANDROID";
|
66
|
+
osTypeEnum["ELSE"] = "ELSE";
|
67
|
+
return osTypeEnum;
|
57
68
|
}({});
|
58
|
-
export var
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
69
|
+
export var terminalTypeEnum = /*#__PURE__*/function (terminalTypeEnum) {
|
70
|
+
terminalTypeEnum["WEB"] = "WEB";
|
71
|
+
terminalTypeEnum["WAP"] = "WAP";
|
72
|
+
terminalTypeEnum["APP"] = "APP";
|
73
|
+
terminalTypeEnum["MINI_APP"] = "MINI_APP";
|
74
|
+
return terminalTypeEnum;
|
63
75
|
}({});
|
64
|
-
export var
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
terminalType["MINI_APP"] = "MINI_APP";
|
69
|
-
return terminalType;
|
76
|
+
export var platformEnum = /*#__PURE__*/function (platformEnum) {
|
77
|
+
platformEnum["desktop"] = "desktop";
|
78
|
+
platformEnum["mobile"] = "mobile";
|
79
|
+
return platformEnum;
|
70
80
|
}({});
|
81
|
+
/**
|
82
|
+
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
83
|
+
*/
|
84
|
+
|
85
|
+
/**
|
86
|
+
* @description Create an event handler, called when the general log triggers during the SDK runtime.
|
87
|
+
*/
|
88
|
+
|
89
|
+
/**
|
90
|
+
* @description Create an event handler, during the running of the sdk, some events are called after execution, and the specific event code is returned.
|
91
|
+
*/
|
92
|
+
|
93
|
+
/**
|
94
|
+
* @description Create an event handler, In pop-up layer mode, the user clicks the semi floating layer close button and is called.
|
95
|
+
*/
|
96
|
+
|
71
97
|
export var messageName = /*#__PURE__*/function (messageName) {
|
72
98
|
messageName["SDK_TO_APP"] = "SDK_TO_APP";
|
73
99
|
messageName["APP_TO_SDK"] = "APP_TO_SDK";
|
74
100
|
messageName["APP_TO_APP"] = "APP_TO_APP";
|
75
101
|
return messageName;
|
76
102
|
}({});
|
77
|
-
export var
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
ERROR["SYSTEM"] = "SYSTEM";
|
82
|
-
ERROR["LOGIN"] = "LOGIN";
|
83
|
-
ERROR["GATEWAY"] = "GATEWAY";
|
84
|
-
ERROR["VALIDATION"] = "VALIDATION";
|
85
|
-
ERROR["TAOBAOBINDALIPAY"] = "TAOBAOBINDALIPAY";
|
86
|
-
ERROR["REGISTERWALLET"] = "REGISTERWALLET";
|
87
|
-
ERROR["NOALIPAYID"] = "NOALIPAYID";
|
88
|
-
ERROR["TRUSTLOGINERROR"] = "TRUSTLOGINERROR";
|
89
|
-
ERROR["SIGNIN"] = "SIGNIN";
|
90
|
-
ERROR["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
|
91
|
-
return ERROR;
|
103
|
+
export var targetEnum = /*#__PURE__*/function (targetEnum) {
|
104
|
+
targetEnum["BLANK"] = "_blank";
|
105
|
+
targetEnum["SELF"] = "_self";
|
106
|
+
return targetEnum;
|
92
107
|
}({});
|
93
|
-
export var
|
94
|
-
|
95
|
-
|
96
|
-
|
108
|
+
export var errorEnum = /*#__PURE__*/function (errorEnum) {
|
109
|
+
errorEnum["PARAMS"] = "PARAMS";
|
110
|
+
errorEnum["TIMEOUT"] = "TIMEOUT";
|
111
|
+
errorEnum["NETWORK"] = "NETWORK";
|
112
|
+
errorEnum["SYSTEM"] = "SYSTEM";
|
113
|
+
errorEnum["LOGIN"] = "LOGIN";
|
114
|
+
errorEnum["GATEWAY"] = "GATEWAY";
|
115
|
+
errorEnum["VALIDATION"] = "VALIDATION";
|
116
|
+
errorEnum["TAOBAOBINDALIPAY"] = "TAOBAOBINDALIPAY";
|
117
|
+
errorEnum["REGISTERWALLET"] = "REGISTERWALLET";
|
118
|
+
errorEnum["NOALIPAYID"] = "NOALIPAYID";
|
119
|
+
errorEnum["TRUSTLOGINERROR"] = "TRUSTLOGINERROR";
|
120
|
+
errorEnum["SIGNIN"] = "SIGNIN";
|
121
|
+
errorEnum["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
|
122
|
+
return errorEnum;
|
97
123
|
}({});
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { Iselector, renderDisplayTypeEnum } from '../types';
|
2
2
|
/**
|
3
|
-
* @description context中需要包含app节点,用于插入
|
3
|
+
* @description context中需要包含app节点,用于插入selector中
|
4
4
|
*/
|
5
|
-
export declare const createIframeNode: (context: any,
|
5
|
+
export declare const createIframeNode: (context: any, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import { getType } from '.';
|
2
2
|
import { ERRORMESSAGE, EVENT } from "../constant";
|
3
|
-
import { messageName } from "../types";
|
3
|
+
import { messageName, renderDisplayTypeEnum } from "../types";
|
4
4
|
/**
|
5
|
-
* @description context中需要包含app节点,用于插入
|
5
|
+
* @description context中需要包含app节点,用于插入selector中
|
6
6
|
*/
|
7
|
-
export var createIframeNode = function createIframeNode(context,
|
7
|
+
export var createIframeNode = function createIframeNode(context, selector, renderDisplayType) {
|
8
8
|
return new Promise(function (resolve, reject) {
|
9
9
|
var dorpinDom = null;
|
10
|
-
if (getType(
|
11
|
-
dorpinDom = document.querySelector(
|
10
|
+
if (getType(selector) === 'string') {
|
11
|
+
dorpinDom = document.querySelector(selector);
|
12
12
|
}
|
13
13
|
if (dorpinDom === null) {
|
14
14
|
var error = {
|
15
|
-
|
16
|
-
|
15
|
+
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
|
16
|
+
message: "Failed to execute 'querySelector' on 'Document': ".concat(selector, " is not a valid selector")
|
17
17
|
};
|
18
18
|
reject(error);
|
19
19
|
context._dispatchToSDK({
|
@@ -26,7 +26,7 @@ export var createIframeNode = function createIframeNode(context, params) {
|
|
26
26
|
});
|
27
27
|
return;
|
28
28
|
}
|
29
|
-
dorpinDom.innerHTML = '';
|
29
|
+
if (renderDisplayType === renderDisplayTypeEnum.popup) dorpinDom.innerHTML = '';
|
30
30
|
if (context.app) {
|
31
31
|
dorpinDom.appendChild(context.app);
|
32
32
|
}
|
package/esm/util/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { errorEnum } from '../types';
|
2
2
|
/**
|
3
3
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
4
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:
|
@@ -31,14 +31,14 @@ declare const safeJson: (data: any, obj: any) => any;
|
|
31
31
|
declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {
|
32
32
|
success: boolean;
|
33
33
|
traceId: string;
|
34
|
-
errorCode:
|
34
|
+
errorCode: errorEnum;
|
35
35
|
resultStatus: any;
|
36
36
|
errorMessage?: undefined;
|
37
37
|
result?: undefined;
|
38
38
|
} | {
|
39
39
|
success: boolean;
|
40
40
|
traceId: string;
|
41
|
-
errorCode:
|
41
|
+
errorCode: errorEnum;
|
42
42
|
errorMessage: string;
|
43
43
|
result: {
|
44
44
|
resultStatus: any;
|
@@ -50,4 +50,6 @@ declare const fomatGetwayError: (headers: Record<string, any>, traceId: string)
|
|
50
50
|
declare const isPC: () => boolean;
|
51
51
|
declare const queryParse: (url?: string) => Record<string, any>;
|
52
52
|
declare const getDesignFontSize: () => number;
|
53
|
-
|
53
|
+
declare const amsSetSize: (event?: any, dom?: any) => void;
|
54
|
+
declare const addSetFontSizeEvent: () => void;
|
55
|
+
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
|
package/esm/util/index.js
CHANGED
@@ -5,7 +5,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
5
5
|
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; }
|
6
6
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
7
7
|
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); }
|
8
|
-
import {
|
8
|
+
import { errorEnum } from "../types";
|
9
9
|
import { get } from "./get";
|
10
10
|
|
11
11
|
/**
|
@@ -174,7 +174,7 @@ var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
|
174
174
|
return {
|
175
175
|
success: false,
|
176
176
|
traceId: traceId,
|
177
|
-
errorCode:
|
177
|
+
errorCode: errorEnum.LOGIN,
|
178
178
|
resultStatus: resultStatus
|
179
179
|
};
|
180
180
|
}
|
@@ -183,7 +183,7 @@ var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
|
183
183
|
return {
|
184
184
|
success: false,
|
185
185
|
traceId: traceId,
|
186
|
-
errorCode:
|
186
|
+
errorCode: errorEnum.TIMEOUT,
|
187
187
|
resultStatus: resultStatus
|
188
188
|
};
|
189
189
|
}
|
@@ -193,7 +193,7 @@ var fomatGetwayError = function fomatGetwayError(headers, traceId) {
|
|
193
193
|
return {
|
194
194
|
success: false,
|
195
195
|
traceId: traceId,
|
196
|
-
errorCode:
|
196
|
+
errorCode: errorEnum.GATEWAY,
|
197
197
|
errorMessage: decodeURIComponent(tips || ''),
|
198
198
|
result: {
|
199
199
|
resultStatus: resultStatus || '',
|
@@ -227,11 +227,26 @@ var queryParse = function queryParse(url) {
|
|
227
227
|
});
|
228
228
|
return qs;
|
229
229
|
};
|
230
|
-
var designSize = 390;
|
231
|
-
var maxFontSize = 130;
|
232
230
|
var getDesignFontSize = function getDesignFontSize() {
|
233
231
|
var screenWidth = document.documentElement.clientWidth;
|
234
|
-
var currentFontSize = isPC() ?
|
235
|
-
return Math.min(currentFontSize,
|
232
|
+
var currentFontSize = isPC() ? 100 : screenWidth * 100 / 390;
|
233
|
+
return Math.min(currentFontSize, 100);
|
236
234
|
};
|
237
|
-
|
235
|
+
var amsSetSize = function amsSetSize(event, dom) {
|
236
|
+
try {
|
237
|
+
var componentContainerId = 'ams-component-container';
|
238
|
+
var _dom = dom || document.getElementById(componentContainerId);
|
239
|
+
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
|
240
|
+
innerHeight = window.innerHeight;
|
241
|
+
// eslint-disable-next-line no-empty
|
242
|
+
} catch (error) {}
|
243
|
+
};
|
244
|
+
var addSetFontSizeEvent = function addSetFontSizeEvent() {
|
245
|
+
window.removeEventListener('resize', amsSetSize);
|
246
|
+
window.removeEventListener('pageShow', amsSetSize);
|
247
|
+
window.removeEventListener('DOMContentLoaded', amsSetSize);
|
248
|
+
window.addEventListener('resize', amsSetSize);
|
249
|
+
window.addEventListener('pageShow', amsSetSize);
|
250
|
+
window.addEventListener('DOMContentLoaded', amsSetSize);
|
251
|
+
};
|
252
|
+
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
|
package/esm/util/mock.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
1
|
export var isLocalMock = function isLocalMock() {
|
2
|
-
|
3
|
-
return ((_window = window) === null || _window === void 0 ? void 0 : (_window$process = _window.process) === null || _window$process === void 0 ? void 0 : (_window$process$env = _window$process.env) === null || _window$process$env === void 0 ? void 0 : _window$process$env.NODE_ENV) === 'MOCK' && window.location.href.indexOf('LOCAL_MOCK=1') > -1;
|
2
|
+
return window.location.href.indexOf('LOCAL_MOCK=1') > -1;
|
4
3
|
};
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@alipay/ams-checkout","version":"0.0.
|
1
|
+
{"name":"@alipay/ams-checkout","version":"0.0.1691743027-dev.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
|