@alipay/ams-checkout 0.0.1693912790-dev.3 → 0.0.1693912790-dev.4

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.
Files changed (36) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/constant/index.d.ts +53 -32
  3. package/esm/constant/index.js +53 -32
  4. package/esm/core/component/index.d.ts +23 -9
  5. package/esm/core/component/index.js +145 -43
  6. package/esm/core/drop-in/index.d.ts +4 -4
  7. package/esm/core/drop-in/index.js +3 -3
  8. package/esm/core/instance/index.d.ts +6 -15
  9. package/esm/core/instance/index.js +31 -53
  10. package/esm/image/skeleton.svg +18 -0
  11. package/esm/index.d.ts +4 -10
  12. package/esm/index.js +8 -30
  13. package/esm/plugin/component/cashierApp.d.ts +1 -1
  14. package/esm/plugin/component/cashierApp.js +16 -15
  15. package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +4 -1
  16. package/esm/plugin/component/component.inline.style.js +38 -0
  17. package/esm/plugin/component/component.popup.style.d.ts +12 -0
  18. package/esm/plugin/component/component.popup.style.js +163 -0
  19. package/esm/plugin/component/index.d.ts +29 -32
  20. package/esm/plugin/component/index.js +231 -339
  21. package/esm/plugin/drop-in/index.d.ts +3 -5
  22. package/esm/plugin/drop-in/index.js +3 -3
  23. package/esm/request/index.d.ts +2 -2
  24. package/esm/request/index.js +3 -3
  25. package/esm/request/utils.d.ts +3 -3
  26. package/esm/request/utils.js +4 -4
  27. package/esm/service/index.d.ts +2 -2
  28. package/esm/types/index.d.ts +71 -34
  29. package/esm/types/index.js +84 -47
  30. package/esm/util/createIframeNode.d.ts +3 -3
  31. package/esm/util/createIframeNode.js +8 -8
  32. package/esm/util/index.d.ts +6 -4
  33. package/esm/util/index.js +22 -5
  34. package/esm/util/mock.js +1 -2
  35. package/package.json +1 -1
  36. package/esm/plugin/component/component.style.js +0 -15
@@ -1,5 +1,5 @@
1
1
  import type AMSCheckout from '../../core/instance';
2
- import type { createPaymentParams, eventPlayload } from '../../types';
2
+ import type { IcreatePaymentParams, eventPlayload } from '../../types';
3
3
  export default class CheckoutApp {
4
4
  app: any;
5
5
  paymentMethodsResult: any;
@@ -16,13 +16,11 @@ export default class CheckoutApp {
16
16
  /**
17
17
  * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
18
18
  */
19
- setRender(createIframeNode: (context: CheckoutApp, renderParams: {
20
- selector: string | HTMLElement;
21
- }) => Promise<void>): void;
19
+ setRender(createIframeNode: any): void;
22
20
  /**
23
21
  * @description High order function of rendering capability
24
22
  */
25
- render(renderParams: createPaymentParams): Promise<void>;
23
+ render(renderParams: IcreatePaymentParams): Promise<void>;
26
24
  /**
27
25
  * @description Cancel listening and destroy the dom
28
26
  */
@@ -185,7 +185,7 @@ var CheckoutApp = /*#__PURE__*/function () {
185
185
  id = 'checkout-dropin';
186
186
  break;
187
187
  case 'COMPONENT':
188
- id = 'checkout-component';
188
+ id = 'ams-checkout-component';
189
189
  break;
190
190
  }
191
191
  return id;
@@ -264,7 +264,7 @@ var CheckoutApp = /*#__PURE__*/function () {
264
264
  appId: BASEPLUGINID,
265
265
  instanceId: this.AMSSDK._instanceId
266
266
  }, data);
267
- this.AMSSDK.eventCenter.emit("".concat(BASEPLUGINID, "-").concat(data.context.event), _data);
267
+ this.AMSSDK._eventCenter.emit("".concat(BASEPLUGINID, "-").concat(data.context.event), _data);
268
268
  }
269
269
  /**
270
270
  * @description Send message to iframe
@@ -288,7 +288,7 @@ var CheckoutApp = /*#__PURE__*/function () {
288
288
  for (var key in eventKeyMap) {
289
289
  // eslint-disable-next-line no-prototype-builtins
290
290
  if (eventKeyMap.hasOwnProperty(key)) {
291
- this.AMSSDK.eventCenter.on("".concat(BASEPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
291
+ this.AMSSDK._eventCenter.on("".concat(BASEPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
292
292
  }
293
293
  }
294
294
  }
@@ -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 { RequestConfig } from '../types';
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: RequestConfig): Promise<T>;
15
+ export declare function request<T>(requestData: Record<string, any> | undefined, options: IrequestConfig): Promise<T>;
@@ -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 { ERROR } from "../types";
20
+ import { errorEnum } from "../types";
21
21
  import { get } from "../util/get";
22
22
  import { getApdidToken, getAppname } from "../util/security";
23
23
  import axios from 'axios';
@@ -136,10 +136,10 @@ function _request() {
136
136
  console.log('request error', _context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message);
137
137
  _error = safeJson(_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.message, {
138
138
  success: false,
139
- errorCode: ERROR.SYSTEM,
139
+ errorCode: errorEnum.SYSTEM,
140
140
  errorMessage: ''
141
141
  });
142
- timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? ERROR.TIMEOUT : '';
142
+ timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
143
143
  errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
144
144
  return _context.abrupt("return", Promise.reject({
145
145
  success: false,
@@ -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 { ERROR } from '../types';
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: ERROR;
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: ERROR;
20
+ errorCode: errorEnum;
21
21
  errorMessage: string;
22
22
  result: {
23
23
  resultStatus: any;
@@ -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 { ERROR } from "../types";
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: ERROR.LOGIN,
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: ERROR.TIMEOUT,
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: ERROR.GATEWAY,
48
+ errorCode: errorEnum.GATEWAY,
49
49
  errorMessage: decodeURIComponent(tips || ''),
50
50
  result: {
51
51
  resultStatus: resultStatus || '',
@@ -1,2 +1,2 @@
1
- import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, RequestConfig } from '../types';
2
- export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<CashierSdkActionQueryResult>;
1
+ import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
2
+ export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: IrequestConfig): Promise<CashierSdkActionQueryResult>;
@@ -8,27 +8,32 @@
8
8
  /**
9
9
  * SDK options
10
10
  */
11
- export interface optionsParams {
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?: (state: any) => void;
19
- onClose?: () => void;
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 interface createPaymentParams {
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: string | HTMLElement;
34
+ selector: Iselector;
30
35
  appearance?: {
31
- displayType?: checkoutDisplay;
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?: IpaymentSessionMetaData;
62
+ paymentSessionMetaData: IpaymentSessionMetaData;
63
+ renderDisplayType: renderDisplayTypeEnum;
64
+ selector?: Iselector;
59
65
  }
60
66
  interface IpaymentSessionConfig {
61
67
  productScene: productSceneEnum;
@@ -84,58 +90,79 @@ export interface IpaymentSessionMetaData {
84
90
  export declare enum localeEnum {
85
91
  'en-US' = "en-US"
86
92
  }
87
- export declare enum checkoutDisplay {
93
+ export declare enum checkoutDisplayEnum {
88
94
  horizon = "horizon",
89
95
  vertical = "vertical"
90
96
  }
91
- export declare enum mode {
97
+ export declare enum modeEnum {
92
98
  dropin = "dropin",
93
99
  component = "component"
94
100
  }
95
- export declare enum networkMode {
101
+ export declare enum networkModeEnum {
96
102
  proxy = "proxy",
97
103
  session = "session"
98
104
  }
99
- export interface checkoutState {
100
- paymentMethodType: string;
105
+ export interface IcheckoutState {
106
+ paymentMethodType?: string;
101
107
  }
102
- export declare enum environment {
108
+ export declare enum environmentEnum {
103
109
  sandbox = "sandbox",
104
110
  prod = "prod",
105
111
  light_sandbox = "light_sandbox"
106
112
  }
107
- export declare enum osType {
113
+ export declare enum osTypeEnum {
108
114
  IOS = "IOS",
109
115
  ANDROID = "ANDROID",
110
116
  ELSE = "ELSE"
111
117
  }
112
- export declare enum terminalType {
118
+ export declare enum terminalTypeEnum {
113
119
  WEB = "WEB",
114
120
  WAP = "WAP",
115
121
  APP = "APP",
116
122
  MINI_APP = "MINI_APP"
117
123
  }
118
- export interface env {
119
- osType?: osType;
120
- terminalType: terminalType;
124
+ export interface Ienv {
125
+ osType?: osTypeEnum;
126
+ terminalType: terminalTypeEnum;
121
127
  environment: string;
122
128
  }
129
+ export declare enum platformEnum {
130
+ desktop = "desktop",
131
+ mobile = "mobile"
132
+ }
133
+ /**
134
+ * @description Create an event handler, called when an error occurs in AMSCheckout.
135
+ */
123
136
  export type callOnError = (state: {
124
- errorMessage: string;
125
- errorCode: string;
137
+ code: string;
138
+ message: string;
126
139
  stack?: any;
127
140
  }) => void;
141
+ /**
142
+ * @description Create an event handler, called when the general log triggers during the SDK runtime.
143
+ */
144
+ export type callOnLog = (state: {
145
+ code: string;
146
+ message: string;
147
+ }) => void;
148
+ /**
149
+ * @description Create an event handler, during the running of the sdk, some events are called after execution, and the specific event code is returned.
150
+ */
151
+ export type callOnEventCallback = (state: {
152
+ code: string;
153
+ message: string;
154
+ }) => void;
128
155
  export type callonPaymentMethodSelected = (state: {
129
156
  paymentMethodType: string;
130
157
  }) => void;
131
158
  export type callOnSizeChanged = (state: {
132
- width: string;
133
- height: string;
134
- }) => void;
135
- export type callOnLog = (state: {
136
- code: string;
137
- message: string;
159
+ width: number;
160
+ height: number;
138
161
  }) => void;
162
+ /**
163
+ * @description Create an event handler, In pop-up layer mode, the user clicks the semi floating layer close button and is called.
164
+ */
165
+ export type callOnClose = () => void;
139
166
  export declare enum messageName {
140
167
  SDK_TO_APP = "SDK_TO_APP",
141
168
  APP_TO_SDK = "APP_TO_SDK",
@@ -152,7 +179,7 @@ export interface eventPlayload {
152
179
  };
153
180
  }
154
181
  export interface AMSCheckoutOptions {
155
- env: env;
182
+ env: Ienv;
156
183
  locale: string;
157
184
  networkMode: string;
158
185
  mode: string;
@@ -161,7 +188,11 @@ export interface AMSCheckoutOptions {
161
188
  export interface Ianalytics {
162
189
  enabled: boolean;
163
190
  }
164
- export declare enum ERROR {
191
+ export declare enum targetEnum {
192
+ BLANK = "_blank",
193
+ SELF = "_self"
194
+ }
195
+ export declare enum errorEnum {
165
196
  PARAMS = "PARAMS",
166
197
  TIMEOUT = "TIMEOUT",
167
198
  NETWORK = "NETWORK",
@@ -176,7 +207,7 @@ export declare enum ERROR {
176
207
  SIGNIN = "SIGNIN",
177
208
  GETSIGNPARAMSERROR = "GETSIGNPARAMSERROR"
178
209
  }
179
- export interface RequestConfig {
210
+ export interface IrequestConfig {
180
211
  env?: string;
181
212
  baseURL?: string;
182
213
  timeout?: number;
@@ -216,13 +247,19 @@ export interface CashierSdkActionQueryResult {
216
247
  schemeUrl?: string;
217
248
  authUrl?: string;
218
249
  }
250
+ export declare enum eventCodeEnum {
251
+ SDK_START_OF_LOADING = "SDK_START_OF_LOADING",
252
+ SDK_END_OF_LOADING = "SDK_END_OF_LOADING",
253
+ SDK_INTERNAL_ERROR = "SDK_INTERNAL_ERROR",
254
+ SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
255
+ SDK_INIT_PARAMETER_ERROR = "SDK_INIT_PARAMETER_ERROR",
256
+ SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
257
+ SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
258
+ SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
259
+ }
219
260
  declare global {
220
261
  interface Window {
221
262
  [key: string]: any;
222
263
  }
223
264
  }
224
- export declare enum Target {
225
- BLANK = "_blank",
226
- SELF = "_self"
227
- }
228
265
  export {};
@@ -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,96 @@ export var localeEnum = /*#__PURE__*/function (localeEnum) {
34
39
  localeEnum["en-US"] = "en-US";
35
40
  return localeEnum;
36
41
  }({});
37
- export var checkoutDisplay = /*#__PURE__*/function (checkoutDisplay) {
38
- checkoutDisplay["horizon"] = "horizon";
39
- checkoutDisplay["vertical"] = "vertical";
40
- return checkoutDisplay;
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 mode = /*#__PURE__*/function (mode) {
43
- mode["dropin"] = "dropin";
44
- mode["component"] = "component";
45
- return mode;
52
+ export var networkModeEnum = /*#__PURE__*/function (networkModeEnum) {
53
+ networkModeEnum["proxy"] = "proxy";
54
+ networkModeEnum["session"] = "session";
55
+ return networkModeEnum;
46
56
  }({});
47
- export var networkMode = /*#__PURE__*/function (networkMode) {
48
- networkMode["proxy"] = "proxy";
49
- networkMode["session"] = "session";
50
- return networkMode;
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 environment = /*#__PURE__*/function (environment) {
53
- environment["sandbox"] = "sandbox";
54
- environment["prod"] = "prod";
55
- environment["light_sandbox"] = "light_sandbox";
56
- return environment;
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 osType = /*#__PURE__*/function (osType) {
59
- osType["IOS"] = "IOS";
60
- osType["ANDROID"] = "ANDROID";
61
- osType["ELSE"] = "ELSE";
62
- return osType;
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 terminalType = /*#__PURE__*/function (terminalType) {
65
- terminalType["WEB"] = "WEB";
66
- terminalType["WAP"] = "WAP";
67
- terminalType["APP"] = "APP";
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 ERROR = /*#__PURE__*/function (ERROR) {
78
- ERROR["PARAMS"] = "PARAMS";
79
- ERROR["TIMEOUT"] = "TIMEOUT";
80
- ERROR["NETWORK"] = "NETWORK";
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;
107
+ }({});
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;
92
123
  }({});
93
- export var Target = /*#__PURE__*/function (Target) {
94
- Target["BLANK"] = "_blank";
95
- Target["SELF"] = "_self";
96
- return Target;
124
+ export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
125
+ eventCodeEnum["SDK_START_OF_LOADING"] = "SDK_START_OF_LOADING";
126
+ eventCodeEnum["SDK_END_OF_LOADING"] = "SDK_END_OF_LOADING";
127
+ eventCodeEnum["SDK_INTERNAL_ERROR"] = "SDK_INTERNAL_ERROR";
128
+ eventCodeEnum["SDK_CREATEPAYMENT_PARAMETER_ERROR"] = "SDK_CREATEPAYMENT_PARAMETER_ERROR";
129
+ eventCodeEnum["SDK_INIT_PARAMETER_ERROR"] = "SDK_INIT_PARAMETER_ERROR";
130
+ eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
131
+ eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
132
+ eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
133
+ return eventCodeEnum;
97
134
  }({});
@@ -1,5 +1,5 @@
1
- import { createPaymentParams, IcreateComponent } from '../types';
1
+ import { Iselector, renderDisplayTypeEnum } from '../types';
2
2
  /**
3
- * @description context中需要包含app节点,用于插入params.selector中
3
+ * @description context中需要包含app节点,用于插入selector中
4
4
  */
5
- export declare const createIframeNode: (context: any, params: createPaymentParams | IcreateComponent) => Promise<void>;
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节点,用于插入params.selector中
5
+ * @description context中需要包含app节点,用于插入selector中
6
6
  */
7
- export var createIframeNode = function createIframeNode(context, params) {
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(params.selector) === 'string') {
11
- dorpinDom = document.querySelector(params.selector);
10
+ if (getType(selector) === 'string') {
11
+ dorpinDom = document.querySelector(selector);
12
12
  }
13
13
  if (dorpinDom === null) {
14
14
  var error = {
15
- errorCode: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode,
16
- errorMessage: "Failed to execute 'querySelector' on 'Document': ".concat(params.selector, " is not a valid selector")
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
  }
@@ -1,4 +1,4 @@
1
- import { ERROR } from '../types';
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: ERROR;
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: ERROR;
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
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, };
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 { ERROR } from "../types";
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: ERROR.LOGIN,
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: ERROR.TIMEOUT,
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: ERROR.GATEWAY,
196
+ errorCode: errorEnum.GATEWAY,
197
197
  errorMessage: decodeURIComponent(tips || ''),
198
198
  result: {
199
199
  resultStatus: resultStatus || '',
@@ -234,4 +234,21 @@ var getDesignFontSize = function getDesignFontSize() {
234
234
  var currentFontSize = isPC() ? maxFontSize : screenWidth * 100 / designSize;
235
235
  return Math.min(currentFontSize, maxFontSize);
236
236
  };
237
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize };
237
+ var amsSetSize = function amsSetSize(event, dom) {
238
+ try {
239
+ var componentContainerId = 'ams-component-container';
240
+ var _dom = dom || document.getElementById(componentContainerId);
241
+ _dom.style.fontSize = "".concat(getDesignFontSize(), "px");
242
+ innerHeight = window.innerHeight;
243
+ // eslint-disable-next-line no-empty
244
+ } catch (error) {}
245
+ };
246
+ var addSetFontSizeEvent = function addSetFontSizeEvent() {
247
+ window.removeEventListener('resize', amsSetSize);
248
+ window.removeEventListener('pageShow', amsSetSize);
249
+ window.removeEventListener('DOMContentLoaded', amsSetSize);
250
+ window.addEventListener('resize', amsSetSize);
251
+ window.addEventListener('pageShow', amsSetSize);
252
+ window.addEventListener('DOMContentLoaded', amsSetSize);
253
+ };
254
+ export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };