@alipay/ams-checkout 0.0.1742382470-dev.4 → 0.0.1743078169-dev.3

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 (56) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/component.inline.style.js +1 -1
  3. package/esm/component/popupWindow.style.js +4 -1
  4. package/esm/constant/index.d.ts +3 -0
  5. package/esm/constant/index.js +3 -0
  6. package/esm/core/component/element/elementContainerService/containerService.d.ts +29 -0
  7. package/esm/core/component/element/elementContainerService/containerService.js +101 -0
  8. package/esm/core/component/element/elementContainerService/index.d.ts +19 -0
  9. package/esm/core/component/element/elementContainerService/index.js +55 -0
  10. package/esm/core/component/element/elementController/index.d.ts +22 -0
  11. package/esm/core/component/element/elementController/index.js +364 -0
  12. package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +17 -0
  13. package/esm/core/component/element/elementProcessor/addressProcessor.js +122 -0
  14. package/esm/core/component/element/elementProcessor/authProcessor.d.ts +14 -0
  15. package/esm/core/component/element/elementProcessor/authProcessor.js +70 -0
  16. package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +36 -0
  17. package/esm/core/component/element/elementProcessor/baseElementProcessor.js +79 -0
  18. package/esm/core/component/element/elementProcessor/paymentProcessor.d.ts +17 -0
  19. package/esm/core/component/element/elementProcessor/paymentProcessor.js +179 -0
  20. package/esm/core/component/element/index.d.ts +8 -46
  21. package/esm/core/component/element/index.js +28 -922
  22. package/esm/core/component/element/type.d.ts +29 -1
  23. package/esm/core/component/element/util.d.ts +58 -0
  24. package/esm/core/component/element/util.js +321 -0
  25. package/esm/core/component/index.d.ts +5 -1
  26. package/esm/core/component/index.js +1 -2
  27. package/esm/core/component/oldElement/index.d.ts +59 -0
  28. package/esm/core/component/oldElement/index.js +956 -0
  29. package/esm/core/component/oldElement/type.d.ts +351 -0
  30. package/esm/core/component/oldElement/type.js +81 -0
  31. package/esm/foundation/core/index.d.ts +6 -1
  32. package/esm/foundation/core/index.js +68 -34
  33. package/esm/foundation/index.d.ts +7 -0
  34. package/esm/foundation/index.js +10 -2
  35. package/esm/foundation/product-processor/element/index.d.ts +7 -0
  36. package/esm/foundation/product-processor/element/index.js +24 -0
  37. package/esm/foundation/service/container/index.d.ts +6 -3
  38. package/esm/foundation/service/container/index.js +19 -7
  39. package/esm/foundation/service/container/popup.d.ts +1 -1
  40. package/esm/foundation/service/event-center.js +1 -0
  41. package/esm/index.js +1 -0
  42. package/esm/plugin/component/cashierApp.d.ts +1 -1
  43. package/esm/plugin/component/index.js +1 -1
  44. package/esm/types/index.d.ts +1 -1
  45. package/esm/types/index.js +1 -1
  46. package/package.json +1 -1
  47. /package/esm/core/component/{element → oldElement}/components/address.d.ts +0 -0
  48. /package/esm/core/component/{element → oldElement}/components/address.js +0 -0
  49. /package/esm/core/component/{element → oldElement}/components/auth.d.ts +0 -0
  50. /package/esm/core/component/{element → oldElement}/components/auth.js +0 -0
  51. /package/esm/core/component/{element → oldElement}/components/payment.d.ts +0 -0
  52. /package/esm/core/component/{element → oldElement}/components/payment.js +0 -0
  53. /package/esm/core/component/{element → oldElement}/mock.d.ts +0 -0
  54. /package/esm/core/component/{element → oldElement}/mock.js +0 -0
  55. /package/esm/core/component/{element → oldElement}/utils.d.ts +0 -0
  56. /package/esm/core/component/{element → oldElement}/utils.js +0 -0
@@ -0,0 +1,351 @@
1
+ import { ActionForm, ConnectErrorCode, IAmount, IAmountView, IPaymentMethod } from '../../../types';
2
+ export declare enum ElementPaymentEvent {
3
+ RENDER_COMPONENT = "renderComponent",
4
+ CAPTURE_ASSET = "onCaptureAsset",
5
+ SIGN_OUT = "onSignout",
6
+ BLUR = "onBlur",
7
+ VALIDATE = "submitPay",
8
+ SUBMIT_RISK = "onSubmitRisk",
9
+ AFTER_SUBMIT = "onAfterSubmit",
10
+ SIZE_CHANGE = "onSizeChange",
11
+ LAUNCH = "onLaunch",
12
+ CALLBACK = "callback",
13
+ SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
14
+ LOG = "log",
15
+ HANDLE_PAYMENT = "handlePayment"
16
+ }
17
+ export declare enum ElementPaymentMethod {
18
+ CONTAINER_ELEMENT = "CONTAINER_ELEMENT",
19
+ AUTH_ELEMENT = "AUTH_ELEMENT",
20
+ ADDRESS_ELEMENT = "ADDRESS_ELEMENT",
21
+ PAYMENT_ELEMENT = "PAYMENT_ELEMENT"
22
+ }
23
+ export declare enum ThemeType {
24
+ NostalgicGray = "nostalgicGray",
25
+ Default = "default",
26
+ Night = "night",
27
+ CherryBlossomPink = "cherryBlossomPink",
28
+ GamingPurple = "gamingPurple",
29
+ AgateGreen = "agateGreen"
30
+ }
31
+ export declare enum ElementType {
32
+ auth = "auth",
33
+ address = "address",
34
+ payment = "payment"
35
+ }
36
+ export declare enum PaymentElementLayout {
37
+ Tabs = "tabs",
38
+ Accordion = "Accordion"
39
+ }
40
+ export declare enum MountElementType {
41
+ auth = "AUTH_ELEMENT",
42
+ address = "ADDRESS_ELEMENT",
43
+ payment = "PAYMENT_ELEMENT"
44
+ }
45
+ export declare const addressTheme: {
46
+ default: string;
47
+ night: string;
48
+ };
49
+ export declare enum EventCallbackCode {
50
+ SDK_CREATE_COMPONENT_ERROR = "SDK_CREATE_COMPONENT_ERROR",
51
+ SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR"
52
+ }
53
+ export declare enum ELEMENT_ENVIRONMENT {
54
+ DEV = "DEV",
55
+ TEST = "TEST",
56
+ SIT = "SIT",
57
+ PRE = "PRE",
58
+ PROD = "PROD",
59
+ SANDBOX = "SANDBOX"
60
+ }
61
+ export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT];
62
+ export interface IElementOptions {
63
+ sessionData: string;
64
+ environment?: ELEMENT_ENVIRONMENT_TYPE;
65
+ locale?: string;
66
+ version?: string;
67
+ appearance?: {
68
+ theme: ThemeType.Default | ThemeType.Night;
69
+ };
70
+ onEventCallback?: ({ code, message, result }: {
71
+ code: EventCallbackCode;
72
+ message: string;
73
+ result?: any;
74
+ }) => void;
75
+ loading?: {
76
+ onStartLoading: () => void;
77
+ onEndLoading: () => void;
78
+ };
79
+ }
80
+ export interface AddressMountComponentsParams {
81
+ configParams?: AddressMountConfig;
82
+ prefillValue: Array<AddressSubmitData>;
83
+ sessionData: string;
84
+ appearance: {
85
+ themeType: string;
86
+ };
87
+ debugProps?: {
88
+ localLink: string;
89
+ };
90
+ elementProps?: {
91
+ elementLink: string;
92
+ };
93
+ }
94
+ interface BaseMountOptions<T = void> {
95
+ configParams?: T;
96
+ sessionData: string;
97
+ debugProps?: {
98
+ localLink: string;
99
+ };
100
+ elementProps?: {
101
+ elementLink: string;
102
+ };
103
+ }
104
+ type HideField = 'shippingCountry' | 'shippingName' | 'shippingPhoneNo' | 'shippingRegion' | 'shippingAddress1' | 'shippingZipCode' | 'shippingAddress2';
105
+ interface AddressMountConfig {
106
+ /**
107
+ * 是否开启地址联想功能
108
+ * 0 开启
109
+ * 1 关闭
110
+ */
111
+ autoSaveAsDefaultAddress?: boolean;
112
+ /**
113
+ * 隐藏部分地址要素
114
+ */
115
+ hideFields?: Array<HideField>;
116
+ }
117
+ export interface AddressMountOptions extends BaseMountOptions<AddressMountConfig> {
118
+ type: ElementType.address;
119
+ prefillValue: Array<AddressSubmitData>;
120
+ appearance?: {
121
+ theme?: ThemeType.Default | ThemeType.Night;
122
+ };
123
+ }
124
+ export interface LinkAuthMountOptions extends BaseMountOptions {
125
+ type: ElementType.auth;
126
+ appearance?: {
127
+ theme?: ThemeType;
128
+ };
129
+ }
130
+ export interface PaymentMountOptions extends BaseMountOptions {
131
+ type: ElementType.payment;
132
+ appearance?: {
133
+ theme?: ThemeType;
134
+ layout?: {
135
+ type: PaymentElementLayout;
136
+ };
137
+ variables?: {
138
+ 'content-primary': string;
139
+ 'content-secondary': string;
140
+ 'content-tertiary': string;
141
+ 'content-quaternary': string;
142
+ 'background-primary': string;
143
+ 'background-secondary': string;
144
+ 'background-disable': string;
145
+ 'background-transparency': string;
146
+ 'border-primary': string;
147
+ 'border-secondary': string;
148
+ 'border-disable': string;
149
+ 'action-normal': string;
150
+ 'action-hover': string;
151
+ 'action-disable': string;
152
+ 'action-secondary': string;
153
+ 'state-failure': string;
154
+ 'state-warning': string;
155
+ 'state-success': string;
156
+ 'state-info': string;
157
+ 'state-marketing': string;
158
+ 'radius-backup': string;
159
+ 'radius-module': string;
160
+ 'radius-component': string;
161
+ 'radius-button': string;
162
+ };
163
+ };
164
+ }
165
+ export declare enum AddressEventCallbackName {
166
+ SHIPPING_CHANGE = "SHIPPING_CHANGE"
167
+ }
168
+ interface BaseMountResult {
169
+ }
170
+ export interface AddressMountResult extends BaseMountResult {
171
+ on: (event: AddressEventCallbackName, callback: (data: any) => void) => void;
172
+ }
173
+ export interface LinkAuthMountResult extends BaseMountResult {
174
+ }
175
+ export interface PaymentMountResult extends BaseMountResult {
176
+ }
177
+ export interface EventCallbackData<T = {}> {
178
+ source?: ElementPaymentMethod;
179
+ target?: ElementPaymentMethod;
180
+ success?: boolean;
181
+ data?: T;
182
+ event?: AddressEventCallbackName;
183
+ }
184
+ export interface ValidateResult<T = {}> {
185
+ success: boolean;
186
+ data: {
187
+ success: boolean;
188
+ data: T;
189
+ };
190
+ }
191
+ export interface AuthSubmitData {
192
+ accountInfo: {
193
+ email: string;
194
+ };
195
+ }
196
+ export interface PaymentSubmitData {
197
+ paymentMethod: {
198
+ paymentMethodType: string;
199
+ paymentMethodDetail?: {
200
+ cardNo?: string;
201
+ };
202
+ cardHolderName?: {
203
+ firstName: string;
204
+ };
205
+ lastName: string;
206
+ };
207
+ paymentFactors: {
208
+ paymentRedirectUrl: string;
209
+ paymentMethodId?: string;
210
+ };
211
+ }
212
+ export interface AddressSubmitData {
213
+ shippingName: {
214
+ firstName: string;
215
+ lastName: string;
216
+ };
217
+ shippingPhoneNo: string;
218
+ shippingAddress: {
219
+ region: string;
220
+ address1: string;
221
+ address2: string;
222
+ city?: string;
223
+ province?: string;
224
+ zipCode: string;
225
+ districts?: string[];
226
+ districtValues?: {
227
+ [key: string]: string;
228
+ };
229
+ };
230
+ notes: string;
231
+ prefer: '1' | '0';
232
+ shippingId: string;
233
+ actionFlag?: 'I' | 'U' | 'D';
234
+ }
235
+ export interface SubmitServiceParams extends PaymentSubmitData {
236
+ accountInfo: AuthSubmitData['accountInfo'];
237
+ shipping?: AddressSubmitData;
238
+ }
239
+ interface SubmitResultActionForm extends ActionForm {
240
+ paymentCodeExpireTime: string;
241
+ }
242
+ export interface SubmitServiceResult {
243
+ success: boolean;
244
+ errorCode: ConnectErrorCode;
245
+ errorMessage: string;
246
+ errorStatus: string;
247
+ traceId: string;
248
+ actionForm?: SubmitResultActionForm;
249
+ codeFormViews?: Array<{
250
+ codeExpireTime?: string;
251
+ }>;
252
+ }
253
+ export interface SubmitFuncResult {
254
+ success: boolean;
255
+ msg: string;
256
+ }
257
+ declare enum AccountStatusEnum {
258
+ EFFECTIVE = "EFFECTIVE",
259
+ UNREGISTERED = "UNREGISTERED"
260
+ }
261
+ type IAccountInfo = {
262
+ email?: string;
263
+ verifyId?: string;
264
+ accountStatus?: AccountStatusEnum;
265
+ oneAccountId?: string;
266
+ needOtp?: boolean;
267
+ errorMsg?: string;
268
+ inputStatus?: 'success' | 'loading' | 'error' | 'focused' | '';
269
+ resendLeftTimes?: number;
270
+ };
271
+ interface ShippingsItem {
272
+ shippingName: {
273
+ firstName: string;
274
+ lastName: string;
275
+ };
276
+ prefer: '1' | '0';
277
+ shippingId: string;
278
+ shippingPhoneNo: string;
279
+ shippingAddress: {
280
+ region: string;
281
+ state: string;
282
+ city: string;
283
+ address1: string;
284
+ address2: string;
285
+ zipCode: string;
286
+ };
287
+ }
288
+ interface Estimate {
289
+ unit: string;
290
+ value: number;
291
+ }
292
+ interface DeliveryEstimate {
293
+ maximum: Estimate;
294
+ minimum: Estimate;
295
+ }
296
+ interface FixedAmount {
297
+ amount: number;
298
+ currency: string;
299
+ }
300
+ interface ShippingRateData {
301
+ displayName: string;
302
+ deliveryEstimate: DeliveryEstimate;
303
+ fixedAmount: FixedAmount;
304
+ }
305
+ interface ShippingAddress {
306
+ address1: string;
307
+ address2: string;
308
+ city: string;
309
+ region: string;
310
+ state: string;
311
+ zipCode: string;
312
+ }
313
+ interface IUserName {
314
+ firstName: string;
315
+ middleName?: string;
316
+ lastName: string;
317
+ fullName?: string;
318
+ }
319
+ type Shippings = ShippingsItem[];
320
+ type IPaymentMethods = IPaymentMethod[];
321
+ interface CKPShipping {
322
+ shippingRateId?: string;
323
+ shippingRateData?: ShippingRateData;
324
+ shippingAddress: ShippingAddress;
325
+ shippingFee?: IAmount;
326
+ shippingFeeView?: IAmountView;
327
+ shippingDescription?: string;
328
+ deliveryEstimate?: DeliveryEstimate;
329
+ shippingFeeId?: string;
330
+ shippingName?: IUserName;
331
+ shippingPhoneNo?: string;
332
+ shipToEmail?: string;
333
+ notes?: string;
334
+ }
335
+ export interface AccountQueryRequest {
336
+ paymentSessionData: string;
337
+ paymentSessionConfig: any;
338
+ accountInfo: IAccountInfo;
339
+ }
340
+ export interface AccountQueryResult {
341
+ accountInfo: IAccountInfo;
342
+ actionForm?: ActionForm;
343
+ paymentMethods: IPaymentMethods;
344
+ shippings: Shippings;
345
+ success: boolean;
346
+ errorCode?: string;
347
+ errorMessage?: string;
348
+ errorStatus?: string;
349
+ shippingInfo?: CKPShipping;
350
+ }
351
+ export {};
@@ -0,0 +1,81 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _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(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ export var ElementPaymentEvent = /*#__PURE__*/function (ElementPaymentEvent) {
6
+ ElementPaymentEvent["RENDER_COMPONENT"] = "renderComponent";
7
+ ElementPaymentEvent["CAPTURE_ASSET"] = "onCaptureAsset";
8
+ ElementPaymentEvent["SIGN_OUT"] = "onSignout";
9
+ ElementPaymentEvent["BLUR"] = "onBlur";
10
+ ElementPaymentEvent["VALIDATE"] = "submitPay";
11
+ ElementPaymentEvent["SUBMIT_RISK"] = "onSubmitRisk";
12
+ ElementPaymentEvent["AFTER_SUBMIT"] = "onAfterSubmit";
13
+ ElementPaymentEvent["SIZE_CHANGE"] = "onSizeChange";
14
+ ElementPaymentEvent["LAUNCH"] = "onLaunch";
15
+ ElementPaymentEvent["CALLBACK"] = "callback";
16
+ ElementPaymentEvent["SEND_MUITI_APP_EVENT_TO_SDK"] = "sendMuitiAppEventToSdk";
17
+ ElementPaymentEvent["LOG"] = "log";
18
+ ElementPaymentEvent["HANDLE_PAYMENT"] = "handlePayment";
19
+ return ElementPaymentEvent;
20
+ }({});
21
+ export var ElementPaymentMethod = /*#__PURE__*/function (ElementPaymentMethod) {
22
+ ElementPaymentMethod["CONTAINER_ELEMENT"] = "CONTAINER_ELEMENT";
23
+ ElementPaymentMethod["AUTH_ELEMENT"] = "AUTH_ELEMENT";
24
+ ElementPaymentMethod["ADDRESS_ELEMENT"] = "ADDRESS_ELEMENT";
25
+ ElementPaymentMethod["PAYMENT_ELEMENT"] = "PAYMENT_ELEMENT";
26
+ return ElementPaymentMethod;
27
+ }({});
28
+ export var ThemeType = /*#__PURE__*/function (ThemeType) {
29
+ ThemeType["NostalgicGray"] = "nostalgicGray";
30
+ ThemeType["Default"] = "default";
31
+ ThemeType["Night"] = "night";
32
+ ThemeType["CherryBlossomPink"] = "cherryBlossomPink";
33
+ ThemeType["GamingPurple"] = "gamingPurple";
34
+ ThemeType["AgateGreen"] = "agateGreen";
35
+ return ThemeType;
36
+ }({});
37
+ export var ElementType = /*#__PURE__*/function (ElementType) {
38
+ ElementType["auth"] = "auth";
39
+ ElementType["address"] = "address";
40
+ ElementType["payment"] = "payment";
41
+ return ElementType;
42
+ }({});
43
+ export var PaymentElementLayout = /*#__PURE__*/function (PaymentElementLayout) {
44
+ PaymentElementLayout["Tabs"] = "tabs";
45
+ PaymentElementLayout["Accordion"] = "Accordion";
46
+ return PaymentElementLayout;
47
+ }({});
48
+ export var MountElementType = /*#__PURE__*/function (MountElementType) {
49
+ MountElementType["auth"] = "AUTH_ELEMENT";
50
+ MountElementType["address"] = "ADDRESS_ELEMENT";
51
+ MountElementType["payment"] = "PAYMENT_ELEMENT";
52
+ return MountElementType;
53
+ }({});
54
+ export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
55
+ export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
56
+ EventCallbackCode["SDK_CREATE_COMPONENT_ERROR"] = "SDK_CREATE_COMPONENT_ERROR";
57
+ EventCallbackCode["SDK_CREATEPAYMENT_PARAMETER_ERROR"] = "SDK_CREATEPAYMENT_PARAMETER_ERROR";
58
+ return EventCallbackCode;
59
+ }({});
60
+ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
61
+ ELEMENT_ENVIRONMENT["DEV"] = "DEV";
62
+ ELEMENT_ENVIRONMENT["TEST"] = "TEST";
63
+ ELEMENT_ENVIRONMENT["SIT"] = "SIT";
64
+ ELEMENT_ENVIRONMENT["PRE"] = "PRE";
65
+ ELEMENT_ENVIRONMENT["PROD"] = "PROD";
66
+ ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
67
+ return ELEMENT_ENVIRONMENT;
68
+ }({});
69
+ // export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
70
+
71
+ export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
72
+ AddressEventCallbackName["SHIPPING_CHANGE"] = "SHIPPING_CHANGE";
73
+ return AddressEventCallbackName;
74
+ }({});
75
+
76
+ // export type IMountResult = AddressMountResult | LinkAuthMountResult | PaymentMountResult;
77
+ var AccountStatusEnum = /*#__PURE__*/function (AccountStatusEnum) {
78
+ AccountStatusEnum["EFFECTIVE"] = "EFFECTIVE";
79
+ AccountStatusEnum["UNREGISTERED"] = "UNREGISTERED";
80
+ return AccountStatusEnum;
81
+ }(AccountStatusEnum || {}); // element 接口start
@@ -1,5 +1,5 @@
1
1
  import { IoptionsParams, ProductSceneEnum } from '../../types';
2
- import { BizFlowStartBehavior, PaymentContext, ProductProcessor, StartBizFlowOptions } from '../index';
2
+ import { BizFlowStartBehavior, IElementStatus, PaymentContext, ProductProcessor, StartBizFlowOptions } from '../index';
3
3
  import { ServiceProvider } from '../service';
4
4
  /**
5
5
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -13,7 +13,11 @@ export declare class AntomSDKCore {
13
13
  private sdkMetaData;
14
14
  private productProcessors;
15
15
  private enablePopWindowEventCallback;
16
+ private status;
16
17
  constructor();
18
+ getStatus(): IElementStatus;
19
+ setStatus(status: any): void;
20
+ updatePaymentSessionData(paymentSession: string): void;
17
21
  registerProcessor(productScene: string, paymentMethod: string, processor: ProductProcessor): void;
18
22
  init(options: IoptionsParams, productScene: ProductSceneEnum): void;
19
23
  private prepare;
@@ -25,4 +29,5 @@ export declare class AntomSDKCore {
25
29
  private handleBehaviorRender;
26
30
  private handleClose;
27
31
  private cleanRender;
32
+ getInstanceId(): string;
28
33
  }
@@ -1,27 +1,28 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
8
  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); } }
9
9
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
10
  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; }
11
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
12
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
13
- import { DisplayTypeEnum, eventCodeEnum } from "../../types";
14
- import { DisplayInfo } from "../index";
15
13
  import { v4 as uuid } from 'uuid';
14
+ import { cleanMockup, createMockup, createRetentionPopup, handleDeclareInfo, hideMockup, hideRetentionPopup, removeRetentionPopup, showRetentionPopup } from "../../component/component.popup.style";
15
+ import { insertStyleSheet } from "../../component/popupWindow.style";
16
+ import { sdkVersion } from "../../config";
17
+ import { COMPONENT_CLOSE_MASK_BLOCK_ID, EVENT, LOADING_ID } from "../../constant";
18
+ import { DisplayTypeEnum, eventCodeEnum } from "../../types";
19
+ import { DisplayInfo, IElementStatus } from "../index";
16
20
  import { ServiceProvider } from "../service";
17
- import { convertPaymentSession, getWebAppVersion, saveWebAppVersion } from "../utils/payment_context_utils";
18
21
  import { getGrayscaleId } from "../utils/gray_scale_utils";
19
- import { sdkVersion } from "../../config";
20
- import { parseWebAppMatchConfig } from "../utils/web_app_url_utils";
22
+ import { convertPaymentSession, getWebAppVersion, saveWebAppVersion } from "../utils/payment_context_utils";
21
23
  import { redirect } from "../utils/redirect_utils";
22
- import { insertStyleSheet } from "../../component/popupWindow.style";
23
- import { hideMockup, createMockup, createRetentionPopup, hideRetentionPopup, showRetentionPopup, cleanMockup, removeRetentionPopup, handleDeclareInfo } from "../../component/component.popup.style";
24
- import { COMPONENT_CLOSE_MASK_BLOCK_ID, EVENT, LOADING_ID } from "../../constant";
24
+ import { parseWebAppMatchConfig } from "../utils/web_app_url_utils";
25
+
25
26
  /**
26
27
  * @author 谦彧 <zhangmian.zm@alipay.com>
27
28
  * @date 2024/9/17
@@ -36,8 +37,34 @@ export var AntomSDKCore = /*#__PURE__*/function () {
36
37
  _defineProperty(this, "sdkMetaData", void 0);
37
38
  _defineProperty(this, "productProcessors", {});
38
39
  _defineProperty(this, "enablePopWindowEventCallback", false);
40
+ _defineProperty(this, "status", IElementStatus.UNINIT);
41
+ this.status = IElementStatus.INITING;
39
42
  }
40
43
  _createClass(AntomSDKCore, [{
44
+ key: "getStatus",
45
+ value: function getStatus() {
46
+ return this.status;
47
+ }
48
+ }, {
49
+ key: "setStatus",
50
+ value: function setStatus(status) {
51
+ if (status === this.getStatus()) return;
52
+ console.log("[test] status has changed from ".concat(this.getStatus(), " to ").concat(status));
53
+ this.status = status;
54
+ }
55
+ }, {
56
+ key: "updatePaymentSessionData",
57
+ value: function updatePaymentSessionData(paymentSession) {
58
+ var _convertPaymentSessio = convertPaymentSession(paymentSession),
59
+ paymentSessionId = _convertPaymentSessio.id,
60
+ paymentSessionMetaData = _convertPaymentSessio.data;
61
+ this.paymentContext = _objectSpread(_objectSpread({}, this.paymentContext), {}, {
62
+ paymentSession: paymentSession,
63
+ paymentSessionId: paymentSessionId,
64
+ paymentSessionObj: paymentSessionMetaData
65
+ });
66
+ }
67
+ }, {
41
68
  key: "registerProcessor",
42
69
  value: function registerProcessor(productScene) {
43
70
  var paymentMethod = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@@ -152,6 +179,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
152
179
  };
153
180
  }());
154
181
  eventCenter.listen(EVENT.destroy.name, function (data) {
182
+ _this.setStatus(IElementStatus.READY);
155
183
  _this.destroy();
156
184
  });
157
185
  eventCenter.listen(EVENT.closeCallback.name, function () {
@@ -182,7 +210,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
182
210
  value: function () {
183
211
  var _startBizFlow = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(options) {
184
212
  var _this$paymentContext$, _this$paymentContext$2, _this$paymentContext$3;
185
- var paymentSession, displayInfo, _convertPaymentSessio, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
213
+ var paymentSession, displayInfo, _convertPaymentSessio2, paymentSessionId, paymentSessionMetaData, mid, webAppMatchConfig, webAppVersion, productScene, paymentMethod, _this$bizFlowStartBeh, payload;
186
214
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
187
215
  while (1) switch (_context3.prev = _context3.next) {
188
216
  case 0:
@@ -192,8 +220,9 @@ export var AntomSDKCore = /*#__PURE__*/function () {
192
220
  }
193
221
  throw new Error('paymentSession is empty');
194
222
  case 2:
223
+ this.setStatus(IElementStatus.IN_BIZ_FLOW);
195
224
  paymentSession = options.paymentSession, displayInfo = options.displayInfo;
196
- _convertPaymentSessio = convertPaymentSession(paymentSession), paymentSessionId = _convertPaymentSessio.id, paymentSessionMetaData = _convertPaymentSessio.data;
225
+ _convertPaymentSessio2 = convertPaymentSession(paymentSession), paymentSessionId = _convertPaymentSessio2.id, paymentSessionMetaData = _convertPaymentSessio2.data;
197
226
  this.paymentContext = {
198
227
  initOptions: this.initOptions,
199
228
  startBizFlowOptions: options,
@@ -216,59 +245,59 @@ export var AntomSDKCore = /*#__PURE__*/function () {
216
245
  // Invoke processor
217
246
  productScene = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentSessionConfig) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.productScene;
218
247
  paymentMethod = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentMethodInfoView) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.paymentMethodType;
219
- _context3.prev = 13;
248
+ _context3.prev = 14;
220
249
  if (!this.productProcessors["".concat(productScene, "|").concat(paymentMethod)]) {
221
- _context3.next = 20;
250
+ _context3.next = 21;
222
251
  break;
223
252
  }
224
- _context3.next = 17;
253
+ _context3.next = 18;
225
254
  return this.productProcessors["".concat(productScene, "|").concat(paymentMethod)].startBizFlow(this.paymentContext);
226
- case 17:
255
+ case 18:
227
256
  this.bizFlowStartBehavior = _context3.sent;
228
- _context3.next = 24;
257
+ _context3.next = 25;
229
258
  break;
230
- case 20:
259
+ case 21:
231
260
  if (!this.productProcessors["".concat(productScene)]) {
232
- _context3.next = 24;
261
+ _context3.next = 25;
233
262
  break;
234
263
  }
235
- _context3.next = 23;
264
+ _context3.next = 24;
236
265
  return this.productProcessors["".concat(productScene)].startBizFlow(this.paymentContext);
237
- case 23:
238
- this.bizFlowStartBehavior = _context3.sent;
239
266
  case 24:
240
- _context3.next = 29;
267
+ this.bizFlowStartBehavior = _context3.sent;
268
+ case 25:
269
+ _context3.next = 30;
241
270
  break;
242
- case 26:
243
- _context3.prev = 26;
244
- _context3.t0 = _context3["catch"](13);
271
+ case 27:
272
+ _context3.prev = 27;
273
+ _context3.t0 = _context3["catch"](14);
245
274
  console.error('Invoke processor failed', _context3.t0);
246
- case 29:
275
+ case 30:
247
276
  if (!(!this.bizFlowStartBehavior || this.bizFlowStartBehavior.behaviorType === 'NONE' || !this.bizFlowStartBehavior.payload)) {
248
- _context3.next = 31;
277
+ _context3.next = 32;
249
278
  break;
250
279
  }
251
280
  return _context3.abrupt("return");
252
- case 31:
281
+ case 32:
253
282
  if (!(this.bizFlowStartBehavior.behaviorType === 'RENDER')) {
254
- _context3.next = 34;
283
+ _context3.next = 35;
255
284
  break;
256
285
  }
257
286
  this.handleBehaviorRender();
258
287
  return _context3.abrupt("return");
259
- case 34:
288
+ case 35:
260
289
  if (!(this.bizFlowStartBehavior.behaviorType === 'REDIRECT')) {
261
- _context3.next = 38;
290
+ _context3.next = 39;
262
291
  break;
263
292
  }
264
293
  payload = (_this$bizFlowStartBeh = this.bizFlowStartBehavior) === null || _this$bizFlowStartBeh === void 0 ? void 0 : _this$bizFlowStartBeh.payload;
265
294
  redirect(payload, this.instanceId);
266
295
  return _context3.abrupt("return");
267
- case 38:
296
+ case 39:
268
297
  case "end":
269
298
  return _context3.stop();
270
299
  }
271
- }, _callee3, this, [[13, 26]]);
300
+ }, _callee3, this, [[14, 27]]);
272
301
  }));
273
302
  function startBizFlow(_x5) {
274
303
  return _startBizFlow.apply(this, arguments);
@@ -394,6 +423,11 @@ export var AntomSDKCore = /*#__PURE__*/function () {
394
423
  cleanElement();
395
424
  }, 300);
396
425
  }
426
+ }, {
427
+ key: "getInstanceId",
428
+ value: function getInstanceId() {
429
+ return this.instanceId;
430
+ }
397
431
  }]);
398
432
  return AntomSDKCore;
399
433
  }();