@alipay/ams-checkout 0.0.1726046231-dev.7 → 0.0.1726046231-dev.9

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.
@@ -9,6 +9,7 @@ export declare class ElementAddressComponent {
9
9
  create(options: {
10
10
  environment: string;
11
11
  locale: string;
12
+ appVersion: string;
12
13
  }): void;
13
14
  mount(sessionData: string, options: ElementAddressMountOptions): Promise<HTMLIFrameElement | undefined>;
14
15
  update(): void;
@@ -15,11 +15,7 @@ export var ElementAddressComponent = /*#__PURE__*/function () {
15
15
  _createClass(ElementAddressComponent, [{
16
16
  key: "create",
17
17
  value: function create(options) {
18
- this.sdk = new AddressComponent({
19
- environment: options.environment,
20
- locale: options.locale,
21
- appVersion: ''
22
- });
18
+ this.sdk = new AddressComponent(options);
23
19
  }
24
20
  }, {
25
21
  key: "mount",
@@ -9,6 +9,7 @@ export declare class ElementPaymentComponent {
9
9
  create(options: {
10
10
  environment: string;
11
11
  locale: string;
12
+ appVersion: string;
12
13
  }): void;
13
14
  mount(sessionData: string, options: ElementPaymentMountOptions): Promise<HTMLIFrameElement | undefined>;
14
15
  update(): void;
@@ -1,4 +1,6 @@
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; }
2
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
5
  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); } }
4
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -15,14 +17,12 @@ export var ElementPaymentComponent = /*#__PURE__*/function () {
15
17
  _createClass(ElementPaymentComponent, [{
16
18
  key: "create",
17
19
  value: function create(options) {
18
- this.sdk = new AMSPaymentElement({
19
- environment: options.environment,
20
- locale: options.locale,
20
+ this.sdk = new AMSPaymentElement(_objectSpread(_objectSpread({}, options), {}, {
21
21
  analytics: {
22
22
  enabled: true
23
23
  },
24
24
  onEventCallback: function onEventCallback(state) {}
25
- });
25
+ }));
26
26
  }
27
27
  }, {
28
28
  key: "mount",
@@ -14,12 +14,14 @@ export declare class ElementComponent {
14
14
  private sdkActionRes;
15
15
  private oneAccountRes;
16
16
  private launchSource;
17
+ private iframeSrc;
17
18
  private mountOptions;
18
19
  private iframes;
19
20
  private componentsCount;
20
21
  private eventCallback;
21
22
  constructor(options: IElementOptions);
22
23
  private createElement;
24
+ private createIframeSrc;
23
25
  private sdkActionQuery;
24
26
  private oneAccountQuery;
25
27
  private addListener;
@@ -22,7 +22,7 @@ import { parseSessionData } from "../index";
22
22
  import { ElementAddressComponent } from "./components/address";
23
23
  import { ElementAuthComponent } from "./components/auth";
24
24
  import { ElementPaymentComponent } from "./components/payment";
25
- import { addressTheme, ThemeType } from "./type";
25
+ import { addressTheme, ThemeType, ELEMENT_ENVIRONMENT } from "./type";
26
26
  var ElementProcessor = /*#__PURE__*/function () {
27
27
  function ElementProcessor() {
28
28
  _classCallCheck(this, ElementProcessor);
@@ -76,6 +76,8 @@ export var ElementComponent = /*#__PURE__*/function () {
76
76
  // one account接口返回
77
77
  _defineProperty(this, "launchSource", void 0);
78
78
  // launch 来源记录
79
+ _defineProperty(this, "iframeSrc", void 0);
80
+ // iframe src记录
79
81
  _defineProperty(this, "mountOptions", void 0);
80
82
  // 组件mount配置记录
81
83
  _defineProperty(this, "iframes", void 0);
@@ -335,6 +337,7 @@ export var ElementComponent = /*#__PURE__*/function () {
335
337
  // this.sendRenderData();
336
338
  // }, 500);
337
339
  });
340
+ this.iframeSrc = this.createIframeSrc(this._options.environment, this._options.version);
338
341
 
339
342
  // 注册 auth 邮箱模块
340
343
  try {
@@ -350,14 +353,16 @@ export var ElementComponent = /*#__PURE__*/function () {
350
353
  this.paymentBase = new ElementPaymentComponent();
351
354
  this.paymentBase.create({
352
355
  environment: this._options.environment,
353
- locale: this._options.locale
356
+ locale: this._options.locale,
357
+ appVersion: this._options.version || ''
354
358
  });
355
359
 
356
360
  // 注册 address 地址模块
357
361
  this.addressBase = new ElementAddressComponent();
358
362
  this.addressBase.create({
359
363
  environment: this._options.environment,
360
- locale: this._options.locale
364
+ locale: this._options.locale,
365
+ appVersion: this._options.version || ''
361
366
  });
362
367
  } catch (error) {
363
368
  var _this$_options$onEven3, _this$_options3;
@@ -370,6 +375,19 @@ export var ElementComponent = /*#__PURE__*/function () {
370
375
  // 注册监听消息
371
376
  this.addListener();
372
377
  }
378
+ }, {
379
+ key: "createIframeSrc",
380
+ value: function createIframeSrc() {
381
+ var env = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ELEMENT_ENVIRONMENT.DEV;
382
+ var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.23.0';
383
+ var baseUrl = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ELEMENT_ENVIRONMENT.DEV, 'https://dev.page.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.TEST, 'http://page.test.alipay.net/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PRE, 'https://cdn-pre.marmot-cloud.com/page/antom-web-checkout-v2'), ELEMENT_ENVIRONMENT.PROD, 'https://checkout.antom.com');
384
+ var _env = (env === null || env === void 0 ? void 0 : env.toLocaleUpperCase()) || ELEMENT_ENVIRONMENT.DEV;
385
+ return {
386
+ auth: "".concat(baseUrl[_env], "/auth-element/").concat(version, "/pages/element_auth/index.html"),
387
+ address: "".concat(baseUrl[_env], "/element-address/").concat(version, "/pages/address/index.html"),
388
+ payment: "".concat(baseUrl[_env], "/elements/").concat(version, "/pages/element_payment/index.html")
389
+ };
390
+ }
373
391
  }, {
374
392
  key: "sdkActionQuery",
375
393
  value: function sdkActionQuery() {
@@ -524,7 +542,8 @@ export var ElementComponent = /*#__PURE__*/function () {
524
542
  configParams: _objectSpread({
525
543
  needEditBackBtn: true,
526
544
  autoSaveAsDefaultAddress: true,
527
- editingNeedShippingQuery: true
545
+ editingNeedShippingQuery: true,
546
+ showTitle: true
528
547
  }, (_this$mountOptions3 = this.mountOptions) === null || _this$mountOptions3 === void 0 ? void 0 : _this$mountOptions3[ElementPaymentMethod.ADDRESS_ELEMENT])
529
548
  }, baseData)
530
549
  }
@@ -597,7 +616,7 @@ export var ElementComponent = /*#__PURE__*/function () {
597
616
  key: "mount",
598
617
  value: function mount(renderOptions, sdkSelector) {
599
618
  if (typeof sdkSelector === 'string') {
600
- var _this$_options$loadin4;
619
+ var _this$_options$loadin4, _renderOptions$debugP2;
601
620
  var element = document.querySelector(sdkSelector);
602
621
  if (!element) {
603
622
  var _this$_options$onEven4, _this$_options7;
@@ -612,8 +631,13 @@ export var ElementComponent = /*#__PURE__*/function () {
612
631
  var _this$_options$loadin5, _this$_options$loadin6;
613
632
  (_this$_options$loadin5 = this._options.loading) === null || _this$_options$loadin5 === void 0 || (_this$_options$loadin6 = _this$_options$loadin5.onStartLoading) === null || _this$_options$loadin6 === void 0 || _this$_options$loadin6.call(_this$_options$loadin5);
614
633
  }
634
+ if (!(renderOptions !== null && renderOptions !== void 0 && (_renderOptions$debugP2 = renderOptions.debugProps) !== null && _renderOptions$debugP2 !== void 0 && _renderOptions$debugP2.localLink)) {
635
+ renderOptions.debugProps = {
636
+ localLink: this.iframeSrc[renderOptions.type]
637
+ };
638
+ }
615
639
  this.loading = true;
616
- if (renderOptions.type === 'linkAuthentication') {
640
+ if (renderOptions.type === 'auth') {
617
641
  return this.mountAuth(renderOptions, sdkSelector);
618
642
  }
619
643
  if (renderOptions.type === 'address') {
@@ -1,7 +1,4 @@
1
1
  import { ConnectErrorCode, ElementPaymentMethod } from '../../../types';
2
- interface BaseMountOptions<T = void> {
3
- config?: {};
4
- }
5
2
  export declare enum ThemeType {
6
3
  NostalgicGray = "nostalgicGray",
7
4
  Default = "default",
@@ -18,11 +15,19 @@ export declare enum EventCallbackCode {
18
15
  Failed = "Failed",
19
16
  Completed = "Completed"
20
17
  }
18
+ export declare enum ELEMENT_ENVIRONMENT {
19
+ DEV = "DEV",
20
+ TEST = "TEST",
21
+ PRE = "PRE",
22
+ PROD = "PROD"
23
+ }
24
+ export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT];
21
25
  export interface IElementOptions {
22
26
  sessionData: string;
23
- environment?: string;
27
+ environment?: ELEMENT_ENVIRONMENT_TYPE;
24
28
  locale?: string;
25
29
  mode?: string;
30
+ version?: string;
26
31
  appearance?: {
27
32
  theme: ThemeType.Default | ThemeType.Night;
28
33
  };
@@ -35,6 +40,12 @@ export interface IElementOptions {
35
40
  onEndLoading: () => void;
36
41
  };
37
42
  }
43
+ interface BaseMountOptions<T = void> {
44
+ config?: {};
45
+ debugProps?: {
46
+ localLink: string;
47
+ };
48
+ }
38
49
  type HideField = 'shippingCountry' | 'shippingName' | 'shippingPhoneNo' | 'shippingRegion' | 'shippingAddress1' | 'shippingZipCode' | 'shippingAddress2';
39
50
  export interface AddressMountOptions extends BaseMountOptions<{
40
51
  /**
@@ -52,27 +63,18 @@ export interface AddressMountOptions extends BaseMountOptions<{
52
63
  appearance?: {
53
64
  theme: ThemeType.Default | ThemeType.Night;
54
65
  };
55
- debugProps?: {
56
- localLink: string;
57
- };
58
66
  }
59
67
  export interface LinkAuthMountOptions extends BaseMountOptions {
60
- type: 'linkAuthentication';
68
+ type: 'auth';
61
69
  appearance?: {
62
70
  theme: ThemeType;
63
71
  };
64
- debugProps?: {
65
- localLink?: string;
66
- };
67
72
  }
68
73
  export interface PaymentMountOptions extends BaseMountOptions {
69
74
  type: 'payment';
70
75
  appearance?: {
71
76
  theme: ThemeType;
72
77
  };
73
- debugProps?: {
74
- localLink: string;
75
- };
76
78
  }
77
79
  export declare enum AddressEventCallbackName {
78
80
  SHIPPING_CHANGE = "SHIPPING_CHANGE"
@@ -17,6 +17,13 @@ export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
17
17
  EventCallbackCode["Completed"] = "Completed";
18
18
  return EventCallbackCode;
19
19
  }({});
20
+ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
21
+ ELEMENT_ENVIRONMENT["DEV"] = "DEV";
22
+ ELEMENT_ENVIRONMENT["TEST"] = "TEST";
23
+ ELEMENT_ENVIRONMENT["PRE"] = "PRE";
24
+ ELEMENT_ENVIRONMENT["PROD"] = "PROD";
25
+ return ELEMENT_ENVIRONMENT;
26
+ }({});
20
27
  // export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
21
28
 
22
29
  export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1726046231-dev.7",
3
+ "version": "0.0.1726046231-dev.9",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",