@alipay/ams-checkout 1.24.0 → 1.25.1

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 (106) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +19 -0
  3. package/esm/component/channel.js +87 -0
  4. package/esm/component/component.inline.style.d.ts +10 -0
  5. package/esm/component/component.inline.style.js +121 -0
  6. package/esm/component/component.popup.style.d.ts +23 -0
  7. package/esm/component/component.popup.style.js +190 -0
  8. package/esm/component/popupWindow.style.d.ts +11 -0
  9. package/esm/component/popupWindow.style.js +121 -0
  10. package/esm/config/index.d.ts +7 -7
  11. package/esm/config/index.js +7 -7
  12. package/esm/constant/index.d.ts +7 -5
  13. package/esm/constant/index.js +9 -78
  14. package/esm/core/bus/interface.d.ts +0 -12
  15. package/esm/core/bus/interface.js +2 -16
  16. package/esm/core/component/address.d.ts +2 -2
  17. package/esm/core/component/appPreloadProcessing.js +0 -2
  18. package/esm/core/component/ckp/index.d.ts +3 -3
  19. package/esm/core/component/element/components/address.js +1 -1
  20. package/esm/core/component/element/components/auth.d.ts +1 -1
  21. package/esm/core/component/element/components/payment.js +1 -1
  22. package/esm/core/component/element/index.js +19 -19
  23. package/esm/core/component/element/type.d.ts +6 -0
  24. package/esm/core/component/index.d.ts +2 -2
  25. package/esm/core/component/index.js +2 -6
  26. package/esm/core/drop-in/index.d.ts +2 -2
  27. package/esm/core/instance/index.d.ts +5 -5
  28. package/esm/core/instance/index.js +1 -2
  29. package/esm/foundation/core/index.d.ts +6 -5
  30. package/esm/foundation/core/index.js +144 -62
  31. package/esm/foundation/index.d.ts +10 -7
  32. package/esm/foundation/product-processor/easysafepay/deps.d.ts +8 -5
  33. package/esm/foundation/product-processor/easysafepay/deps.js +5 -2
  34. package/esm/foundation/product-processor/easysafepay/index.d.ts +6 -6
  35. package/esm/foundation/product-processor/easysafepay/index.js +192 -265
  36. package/esm/foundation/service/{event-bus → api-bus}/ability/callback.js +1 -1
  37. package/esm/foundation/service/{event-bus → api-bus}/ability/globalData.d.ts +1 -1
  38. package/esm/{core/bus → foundation/service/api-bus}/ability/globalData.js +2 -2
  39. package/esm/{core/bus → foundation/service/api-bus}/ability/request.d.ts +1 -1
  40. package/esm/{core/bus → foundation/service/api-bus}/ability/request.js +2 -2
  41. package/esm/foundation/service/{event-bus → api-bus}/ability/security.js +29 -19
  42. package/esm/foundation/service/{event-bus → api-bus}/ability/tracker.js +1 -1
  43. package/esm/foundation/service/{event-bus → api-bus}/busManager.js +1 -1
  44. package/esm/foundation/service/{event-bus → api-bus}/index.d.ts +2 -2
  45. package/esm/foundation/service/api-bus/interface.d.ts +48 -0
  46. package/esm/foundation/service/api-bus/interface.js +54 -0
  47. package/esm/foundation/service/container/index.d.ts +4 -2
  48. package/esm/foundation/service/container/index.js +49 -5
  49. package/esm/foundation/service/container/popup.js +1 -1
  50. package/esm/foundation/service/event-center.d.ts +12 -6
  51. package/esm/foundation/service/event-center.js +28 -18
  52. package/esm/foundation/service/global-data/index.d.ts +2 -2
  53. package/esm/foundation/service/global-data/index.js +4 -5
  54. package/esm/foundation/service/index.d.ts +2 -2
  55. package/esm/foundation/service/index.js +1 -1
  56. package/esm/foundation/service/log/index.d.ts +2 -2
  57. package/esm/foundation/service/log/index.js +1 -1
  58. package/esm/foundation/service/requester/deps.d.ts +1 -1
  59. package/esm/foundation/service/requester/requester.d.ts +2 -2
  60. package/esm/foundation/service/requester/requester.js +14 -11
  61. package/esm/foundation/service/security/index.d.ts +11 -9
  62. package/esm/foundation/service/security/index.js +114 -44
  63. package/esm/foundation/utils/payment_product_utils.d.ts +13 -0
  64. package/esm/foundation/utils/payment_product_utils.js +38 -0
  65. package/esm/foundation/utils/redirect_utils.d.ts +5 -0
  66. package/esm/foundation/utils/redirect_utils.js +209 -45
  67. package/esm/foundation/utils/system_events.js +0 -5
  68. package/esm/foundation/utils/web_app_url_utils.d.ts +11 -2
  69. package/esm/foundation/utils/web_app_url_utils.js +18 -3
  70. package/esm/index.d.ts +13 -12
  71. package/esm/index.js +36 -31
  72. package/esm/plugin/component/cashierApp.d.ts +3 -3
  73. package/esm/plugin/component/cashierApp.js +9 -10
  74. package/esm/plugin/component/component.inline.style.d.ts +1 -1
  75. package/esm/plugin/component/component.inline.style.js +2 -3
  76. package/esm/plugin/component/component.popup.style.d.ts +1 -10
  77. package/esm/plugin/component/component.popup.style.js +10 -28
  78. package/esm/plugin/component/index.d.ts +1 -1
  79. package/esm/plugin/component/index.js +64 -62
  80. package/esm/plugin/payment-element/utils.d.ts +1 -1
  81. package/esm/plugin/payment-element/utils.js +1 -2
  82. package/esm/plugin/type.d.ts +1 -1
  83. package/esm/types/index.d.ts +17 -11
  84. package/esm/types/index.js +7 -1
  85. package/esm/util/getBackScheme.js +95 -3
  86. package/esm/util/index.d.ts +1 -1
  87. package/esm/util/index.js +4 -3
  88. package/esm/util/security.d.ts +33 -0
  89. package/esm/{foundation/service/event-bus/ability/request.js → util/security.js} +153 -122
  90. package/package.json +1 -1
  91. package/esm/core/bus/ability/globalData.d.ts +0 -10
  92. package/esm/foundation/service/event-bus/ability/globalData.js +0 -89
  93. package/esm/foundation/service/event-bus/ability/request.d.ts +0 -10
  94. package/esm/foundation/types/index.d.ts +0 -4
  95. package/esm/foundation/types/index.js +0 -4
  96. package/esm/util/ua/index.d.ts +0 -2
  97. package/esm/util/ua/index.js +0 -2
  98. package/esm/util/ua/isAndroid.d.ts +0 -4
  99. package/esm/util/ua/isAndroid.js +0 -7
  100. package/esm/util/ua/isIOS.d.ts +0 -4
  101. package/esm/util/ua/isIOS.js +0 -7
  102. /package/esm/foundation/service/{event-bus → api-bus}/ability/callback.d.ts +0 -0
  103. /package/esm/foundation/service/{event-bus → api-bus}/ability/security.d.ts +0 -0
  104. /package/esm/foundation/service/{event-bus → api-bus}/ability/tracker.d.ts +0 -0
  105. /package/esm/foundation/service/{event-bus → api-bus}/busManager.d.ts +0 -0
  106. /package/esm/foundation/service/{event-bus → api-bus}/index.js +0 -0
@@ -12,7 +12,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
12
12
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
14
  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); }
15
- import { SDKCallbackActionEnum } from "../../../../core/bus/interface";
15
+ import { SDKCallbackActionEnum } from "../interface";
16
16
  import { BusSubscriber } from "../busManager";
17
17
  export var SDKCallbackBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
18
18
  _inherits(SDKCallbackBusSubscriber, _BusSubscriber);
@@ -1,4 +1,4 @@
1
- import { BusContext, BusMessage, BusSubscriber } from '../../../../foundation/service/event-bus/busManager';
1
+ import { BusContext, BusMessage, BusSubscriber } from '../../../../foundation/service/api-bus/busManager';
2
2
  export declare class DataBusSubscriber extends BusSubscriber {
3
3
  private instanceId;
4
4
  constructor(instanceId: string);
@@ -12,8 +12,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
12
12
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
14
  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); }
15
- import { ServiceProvider } from "../../../foundation/service";
16
- import { BusSubscriber } from "../../../foundation/service/event-bus/busManager";
15
+ import { ServiceProvider } from "../../../../foundation/service";
16
+ import { BusSubscriber } from "../../../../foundation/service/api-bus/busManager";
17
17
  import { DataActiontEnum } from "../interface";
18
18
  export var DataBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
19
19
  _inherits(DataBusSubscriber, _BusSubscriber);
@@ -1,4 +1,4 @@
1
- import { BusContext, BusMessage, BusSubscriber } from "../../../foundation/service/event-bus/busManager";
1
+ import { BusContext, BusMessage, BusSubscriber } from "../../../../foundation/service/api-bus/busManager";
2
2
  export declare class RequestBusSubscriber extends BusSubscriber {
3
3
  private instanceId;
4
4
  constructor(instanceId: string);
@@ -16,8 +16,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  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); }
18
18
  import { RequestActiontEnum } from "../interface";
19
- import { BusSubscriber } from "../../../foundation/service/event-bus/busManager";
20
- import { ServiceProvider } from "../../../foundation/service";
19
+ import { BusSubscriber } from "../../../../foundation/service/api-bus/busManager";
20
+ import { ServiceProvider } from "../../../../foundation/service";
21
21
  export var RequestBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
22
22
  _inherits(RequestBusSubscriber, _BusSubscriber);
23
23
  var _super = _createSuper(RequestBusSubscriber);
@@ -16,7 +16,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  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); }
18
18
  import { BusSubscriber } from "../busManager";
19
- import { SecuritySDKActionEnum } from "../../../../core/bus/interface";
19
+ import { SecuritySDKActionEnum } from "../interface";
20
20
  import { ServiceProvider } from "../../../../foundation/service";
21
21
  export var SecurityBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
22
22
  _inherits(SecurityBusSubscriber, _BusSubscriber);
@@ -43,18 +43,23 @@ export var SecurityBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
43
43
  while (1) switch (_context.prev = _context.next) {
44
44
  case 0:
45
45
  console.log('preInitSecurity', message);
46
- try {
47
- securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
48
- securityService.initSecurity(true);
49
- context === null || context === void 0 || context.onCallBack(message.result(true));
50
- } catch (error) {
51
- context === null || context === void 0 || context.onCallBack(message.result(false));
52
- }
53
- case 2:
46
+ _context.prev = 1;
47
+ securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
48
+ _context.next = 5;
49
+ return securityService.preInitSecurity();
50
+ case 5:
51
+ context === null || context === void 0 || context.onCallBack(message.result(true));
52
+ _context.next = 11;
53
+ break;
54
+ case 8:
55
+ _context.prev = 8;
56
+ _context.t0 = _context["catch"](1);
57
+ context === null || context === void 0 || context.onCallBack(message.result(false));
58
+ case 11:
54
59
  case "end":
55
60
  return _context.stop();
56
61
  }
57
- }, _callee, this);
62
+ }, _callee, this, [[1, 8]]);
58
63
  }));
59
64
  function preInitSecurity(_x, _x2) {
60
65
  return _preInitSecurity.apply(this, arguments);
@@ -70,18 +75,23 @@ export var SecurityBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
70
75
  while (1) switch (_context2.prev = _context2.next) {
71
76
  case 0:
72
77
  console.log('initSecurity', message);
73
- try {
74
- securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
75
- securityService.initSecurity();
76
- context === null || context === void 0 || context.onCallBack(message.result(true));
77
- } catch (error) {
78
- context === null || context === void 0 || context.onCallBack(message.result(false));
79
- }
80
- case 2:
78
+ _context2.prev = 1;
79
+ securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
80
+ _context2.next = 5;
81
+ return securityService.initSecurity();
82
+ case 5:
83
+ context === null || context === void 0 || context.onCallBack(message.result(true));
84
+ _context2.next = 11;
85
+ break;
86
+ case 8:
87
+ _context2.prev = 8;
88
+ _context2.t0 = _context2["catch"](1);
89
+ context === null || context === void 0 || context.onCallBack(message.result(false));
90
+ case 11:
81
91
  case "end":
82
92
  return _context2.stop();
83
93
  }
84
- }, _callee2, this);
94
+ }, _callee2, this, [[1, 8]]);
85
95
  }));
86
96
  function initSecurity(_x3, _x4) {
87
97
  return _initSecurity.apply(this, arguments);
@@ -16,7 +16,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
16
16
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
17
  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); }
18
18
  import { BusSubscriber } from "../busManager";
19
- import { TrackerActionEnum } from "../../../../core/bus/interface";
19
+ import { TrackerActionEnum } from "../interface";
20
20
  import { ServiceProvider } from "../../../../foundation/service";
21
21
  export var TrackerBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
22
22
  _inherits(TrackerBusSubscriber, _BusSubscriber);
@@ -10,7 +10,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
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 { ServiceProvider } from "../../../foundation/product-processor/easysafepay/deps";
13
+ import { ServiceProvider } from '..';
14
14
  /**
15
15
  * Bus 埋点内容定义
16
16
  */
@@ -1,5 +1,5 @@
1
1
  import { Service } from '../../index';
2
- import { IOptionsParams } from '../../../types';
2
+ import { IoptionsParams } from '../../../types';
3
3
  import { LogService } from '../log';
4
4
  import { BusMessage, BusSubscriber, OnBusCallback } from './busManager';
5
5
  /**
@@ -10,7 +10,7 @@ export declare class ApiBusManagerService implements Service {
10
10
  protected logger: LogService;
11
11
  protected instanceId: string;
12
12
  private busManager;
13
- init(initOptions: IOptionsParams, instanceId: string): void;
13
+ init(initOptions: IoptionsParams, instanceId: string): void;
14
14
  subscribe(subscriber: BusSubscriber): void;
15
15
  unsubscribe(subscriber: BusSubscriber): void;
16
16
  isSubscribed(actionName: string): boolean;
@@ -0,0 +1,48 @@
1
+ export declare enum PaymentActionEnum {
2
+ optional_init = "plugin_optional_init"
3
+ }
4
+ export declare enum ApplePayActionEnum {
5
+ canMakePayments = "plugin_CARD_APPLE_PAY_available",
6
+ createComponent = "plugin_CARD_APPLE_PAY_createComponent",
7
+ destroyComponent = "plugin_CARD_APPLE_PAY_destroyComponent"
8
+ }
9
+ export declare enum PaypalActionEnum {
10
+ mountComponent = "plugin_Paypal_mountComponent",
11
+ destroyComponent = "plugin_Paypal_destroyComponent"
12
+ }
13
+ export declare enum SDKCallbackActionEnum {
14
+ onEventCallback = "onEventCallback"
15
+ }
16
+ export declare enum RequestActiontEnum {
17
+ request = "request",
18
+ getEnvInfo = "getEnvInfo",
19
+ getUserAgent = "getUserAgent"
20
+ }
21
+ export declare enum DataActiontEnum {
22
+ getGlobalData = "getGlobalData",
23
+ setGlobalData = "setGlobalData",
24
+ clearGlobalData = "clearGlobalData"
25
+ }
26
+ export declare enum SecuritySDKActionEnum {
27
+ preInitSecurity = "preInitSecurity",
28
+ initSecurity = "initSecurity",
29
+ getSecurityDeviceId = "getSecurityDeviceId"
30
+ }
31
+ export declare enum TrackerActionEnum {
32
+ /**
33
+ * level: string info/error
34
+ * basic: json object
35
+ * extra: json object
36
+ */
37
+ reportAnalytics = "reportAnalytics"
38
+ }
39
+ export declare enum ComponentActiontEnum {
40
+ onDestory = "onDestory"
41
+ }
42
+ export declare enum RequestActiontEnum {
43
+ onDestory = "httpRequest"
44
+ }
45
+ export declare enum LoadingActiontEnum {
46
+ showLoading = "showLoading",
47
+ dismissLoading = "dismissLoading"
48
+ }
@@ -0,0 +1,54 @@
1
+ export var PaymentActionEnum = /*#__PURE__*/function (PaymentActionEnum) {
2
+ PaymentActionEnum["optional_init"] = "plugin_optional_init";
3
+ return PaymentActionEnum;
4
+ }({});
5
+ export var ApplePayActionEnum = /*#__PURE__*/function (ApplePayActionEnum) {
6
+ ApplePayActionEnum["canMakePayments"] = "plugin_CARD_APPLE_PAY_available";
7
+ ApplePayActionEnum["createComponent"] = "plugin_CARD_APPLE_PAY_createComponent";
8
+ ApplePayActionEnum["destroyComponent"] = "plugin_CARD_APPLE_PAY_destroyComponent";
9
+ return ApplePayActionEnum;
10
+ }({});
11
+ export var PaypalActionEnum = /*#__PURE__*/function (PaypalActionEnum) {
12
+ PaypalActionEnum["mountComponent"] = "plugin_Paypal_mountComponent";
13
+ PaypalActionEnum["destroyComponent"] = "plugin_Paypal_destroyComponent";
14
+ return PaypalActionEnum;
15
+ }({});
16
+ export var SDKCallbackActionEnum = /*#__PURE__*/function (SDKCallbackActionEnum) {
17
+ SDKCallbackActionEnum["onEventCallback"] = "onEventCallback";
18
+ return SDKCallbackActionEnum;
19
+ }({});
20
+ export var RequestActiontEnum = /*#__PURE__*/function (RequestActiontEnum) {
21
+ RequestActiontEnum["request"] = "request";
22
+ RequestActiontEnum["getEnvInfo"] = "getEnvInfo";
23
+ RequestActiontEnum["getUserAgent"] = "getUserAgent";
24
+ return RequestActiontEnum;
25
+ }({});
26
+ export var DataActiontEnum = /*#__PURE__*/function (DataActiontEnum) {
27
+ DataActiontEnum["getGlobalData"] = "getGlobalData";
28
+ DataActiontEnum["setGlobalData"] = "setGlobalData";
29
+ DataActiontEnum["clearGlobalData"] = "clearGlobalData";
30
+ return DataActiontEnum;
31
+ }({});
32
+ export var SecuritySDKActionEnum = /*#__PURE__*/function (SecuritySDKActionEnum) {
33
+ SecuritySDKActionEnum["preInitSecurity"] = "preInitSecurity";
34
+ SecuritySDKActionEnum["initSecurity"] = "initSecurity";
35
+ SecuritySDKActionEnum["getSecurityDeviceId"] = "getSecurityDeviceId";
36
+ return SecuritySDKActionEnum;
37
+ }({});
38
+ export var TrackerActionEnum = /*#__PURE__*/function (TrackerActionEnum) {
39
+ TrackerActionEnum["reportAnalytics"] = "reportAnalytics";
40
+ return TrackerActionEnum;
41
+ }({});
42
+ export var ComponentActiontEnum = /*#__PURE__*/function (ComponentActiontEnum) {
43
+ ComponentActiontEnum["onDestory"] = "onDestory";
44
+ return ComponentActiontEnum;
45
+ }({});
46
+ RequestActiontEnum = /*#__PURE__*/function (RequestActiontEnum) {
47
+ RequestActiontEnum["onDestory"] = "httpRequest";
48
+ return RequestActiontEnum;
49
+ }(RequestActiontEnum || {});
50
+ export var LoadingActiontEnum = /*#__PURE__*/function (LoadingActiontEnum) {
51
+ LoadingActiontEnum["showLoading"] = "showLoading";
52
+ LoadingActiontEnum["dismissLoading"] = "dismissLoading";
53
+ return LoadingActiontEnum;
54
+ }({});
@@ -1,5 +1,5 @@
1
1
  import { DisplayInfo, SDKMetaData, Service } from '../../index';
2
- import { IOptionsParams } from '../../../types';
2
+ import { IoptionsParams } from '../../../types';
3
3
  export declare class ContainerService implements Service {
4
4
  private instanceId;
5
5
  private sdkMetaData;
@@ -9,9 +9,10 @@ export declare class ContainerService implements Service {
9
9
  private logService;
10
10
  private displayInfo;
11
11
  private webApp;
12
+ private _webAppHeartBeatTimeoutFn;
12
13
  private customizedLoadingListener;
13
14
  destroy(): void;
14
- init(initOptions: IOptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
15
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
15
16
  update(): void;
16
17
  load(displayInfo: DisplayInfo, url: string, closeBtnFunc: () => void): HTMLDivElement;
17
18
  cleanContainer(displayInfo: DisplayInfo): void;
@@ -24,5 +25,6 @@ export declare class ContainerService implements Service {
24
25
  private addCapabilityToEventCenter;
25
26
  private addCapabilityToApiBusManager;
26
27
  private handleSizeChanged;
28
+ private handleAppHeartBeat;
27
29
  private changeCloseBtnVisibility;
28
30
  }
@@ -9,11 +9,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
9
9
  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); }
10
10
  import { DisplayTypeEnum } from "../../../types";
11
11
  import { createIframe, createPreloadIframe, startSizeChangeAnim } from "./utils";
12
- import { addInlineLoading, createInlineBaseElement } from "../../../plugin/component/component.inline.style";
13
- import { addPopupLoading, createBaseElement } from "../../../plugin/component/component.popup.style";
12
+ import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
13
+ import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
14
14
  import { COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, ERRORMESSAGE, LOADING_ID, MOCKUP_ID } from "../../../constant";
15
15
  import { ServiceProvider } from "../index";
16
- import { EVENT } from "../../../constant";
16
+ import { EVENT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../../constant";
17
17
  import { PopupManager } from "./popup";
18
18
  /**
19
19
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -31,6 +31,7 @@ export var ContainerService = /*#__PURE__*/function () {
31
31
  _defineProperty(this, "logService", void 0);
32
32
  _defineProperty(this, "displayInfo", void 0);
33
33
  _defineProperty(this, "webApp", void 0);
34
+ _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
34
35
  // if this variable is true, SDK will invoke listener instead of showing loading
35
36
  _defineProperty(this, "customizedLoadingListener", void 0);
36
37
  }
@@ -54,8 +55,9 @@ export var ContainerService = /*#__PURE__*/function () {
54
55
  }, {
55
56
  key: "load",
56
57
  value: function load(displayInfo, url, closeBtnFunc) {
57
- console.log('load');
58
- var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId && "-".concat(displayInfo.selector)));
58
+ var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(displayInfo.selector) : ''));
59
+ this.webApp = webApp;
60
+ this.displayInfo = displayInfo;
59
61
  webApp.src = url;
60
62
  this.eventCenter.addIFrame(webApp);
61
63
  if (webApp.src.includes('?')) {
@@ -80,6 +82,8 @@ export var ContainerService = /*#__PURE__*/function () {
80
82
  }
81
83
  var container = document.getElementById(COMPONENT_CONTAINER_ID);
82
84
  if (container) container === null || container === void 0 || container.remove();
85
+ this.webApp = null;
86
+ this.eventCenter.cleanIFrames();
83
87
 
84
88
  // animation
85
89
  (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
@@ -202,6 +206,9 @@ export var ContainerService = /*#__PURE__*/function () {
202
206
  this.eventCenter.listen(EVENT.hideCloseButton.name, function () {
203
207
  _this2.changeCloseBtnVisibility(false);
204
208
  });
209
+ this.eventCenter.listen(EVENT.appHeartBeat.name, function () {
210
+ _this2.handleAppHeartBeat();
211
+ });
205
212
  }
206
213
  }, {
207
214
  key: "addCapabilityToApiBusManager",
@@ -241,6 +248,43 @@ export var ContainerService = /*#__PURE__*/function () {
241
248
  this.webApp.style.height = "".concat(data.height, "px");
242
249
  }
243
250
  }
251
+ }, {
252
+ key: "handleAppHeartBeat",
253
+ value: function handleAppHeartBeat() {
254
+ var _this3 = this;
255
+ try {
256
+ if (!this._webAppHeartBeatTimeoutFn) {
257
+ this._webAppHeartBeatTimeoutFn = function () {
258
+ if (_this3.webApp && _this3.displayInfo) {
259
+ _this3.logService.logError({
260
+ title: 'sdk_error_appHeartBeatTimeout'
261
+ });
262
+ }
263
+ };
264
+ }
265
+ if (window._webAppHeartBeatTimeoutId) {
266
+ clearTimeout(window._webAppHeartBeatTimeoutId);
267
+ window._webAppHeartBeatTimeoutId = null;
268
+ }
269
+ if (this._webAppHeartBeatTimeoutFn) {
270
+ window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
271
+ }
272
+ setTimeout(function () {
273
+ if (_this3.webApp && _this3.displayInfo) {
274
+ _this3.eventCenter.dispatchToApp({
275
+ event: 'sdkHeartBeat',
276
+ data: {}
277
+ });
278
+ }
279
+ }, TIME_DELAY_SEND_HEART_BEAT);
280
+ } catch (error) {
281
+ this.logService.logError({
282
+ title: 'sdk_error_handleAppHeartBeat'
283
+ }, {
284
+ errorMessage: error.message
285
+ });
286
+ }
287
+ }
244
288
  }, {
245
289
  key: "changeCloseBtnVisibility",
246
290
  value: function changeCloseBtnVisibility(isShow) {
@@ -8,7 +8,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
8
8
  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; }
9
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
10
  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); }
11
- import { createModal, destroyModal } from "../../../plugin/component/popupWindow.style";
11
+ import { createModal, destroyModal } from "../../../component/popupWindow.style";
12
12
  import { LOADTIME_LIMIT, POPUP_LOADTIME_LOG_LIMIT } from "../../../constant";
13
13
  /**
14
14
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -1,5 +1,5 @@
1
- import { EventPayload, EventPayloadContext } from '../../types';
2
- import { Service } from '../index';
1
+ import { EventPayload, EventPayloadContext, IoptionsParams } from '../../types';
2
+ import { SDKMetaData, Service } from '../index';
3
3
  /**
4
4
  * @author 江跃 <jiangbin.gjb@antgroup.com>
5
5
  * @date 2024/9/17
@@ -7,11 +7,12 @@ import { Service } from '../index';
7
7
  export declare class EventCenter implements Service {
8
8
  private events;
9
9
  private iframes;
10
+ private instanceId;
10
11
  constructor();
11
12
  /**
12
13
  * Initializes the event center
13
14
  */
14
- init(): void;
15
+ init(initOptions: IoptionsParams, instanceId: string, sdkMetaData: SDKMetaData): void;
15
16
  /**
16
17
  * Cleans up event listeners when the event center is destroyed.
17
18
  */
@@ -26,6 +27,10 @@ export declare class EventCenter implements Service {
26
27
  * @param domain - The domain of the app.
27
28
  */
28
29
  addIFrame(iframe: HTMLIFrameElement): void;
30
+ /**
31
+ * Cleans iframes when web app close
32
+ */
33
+ cleanIFrames(): void;
29
34
  removeIFrame(iframe: HTMLIFrameElement): void;
30
35
  /**
31
36
  * Handles messages received from the app.
@@ -41,8 +46,9 @@ export declare class EventCenter implements Service {
41
46
  * Listens to an event by adding a callback function.
42
47
  * @param name - The name of the event to listen for.
43
48
  * @param func - The callback function to execute when the event is emitted.
49
+ * @param isAppend - Append to event handlers as chain, default value is false
44
50
  */
45
- listen(name: string, func: IListener): void;
51
+ listen(name: string, func: IListener, isAppend?: boolean): void;
46
52
  /**
47
53
  * Unsubscribes from an event. If a function is provided, only that function is removed.
48
54
  * @param name - The name of the event to unlisten to.
@@ -54,7 +60,7 @@ export declare class EventCenter implements Service {
54
60
  * @param name - The name of the event to emit.
55
61
  * @param data - The event data to pass to the event listeners.
56
62
  */
57
- emit(name: string, data: any, eventPayload?: EventPayload): void;
63
+ emit(name: string, data: any, EventPayload?: EventPayload): void;
58
64
  /**
59
65
  * Registers a callback for an event and immediately dispatches the event to the app.
60
66
  * @param payloadContext - The context containing event information and callback ID.
@@ -70,6 +76,6 @@ export declare class EventCenter implements Service {
70
76
  isExist(name: string): boolean;
71
77
  }
72
78
  interface IListener {
73
- (data: any, eventPayload?: EventPayload): void;
79
+ (data: any, EventPayload?: EventPayload): void;
74
80
  }
75
81
  export {};
@@ -9,7 +9,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
9
9
  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); }
10
10
  import { v4 as uuid } from 'uuid';
11
11
  import { ERRORMESSAGE } from "../../constant";
12
- import { MessageName } from "../../types";
12
+ import { EventPayload, MessageName } from "../../types";
13
13
  import { isJsonString } from "../../util";
14
14
  import { getIframeOrigin, registerSystemEvents, unRegisterSystemEvents } from "../utils/system_events";
15
15
 
@@ -22,6 +22,7 @@ export var EventCenter = /*#__PURE__*/function () {
22
22
  _classCallCheck(this, EventCenter);
23
23
  _defineProperty(this, "events", void 0);
24
24
  _defineProperty(this, "iframes", void 0);
25
+ _defineProperty(this, "instanceId", void 0);
25
26
  this.events = new Map();
26
27
  this.iframes = [];
27
28
  }
@@ -31,7 +32,8 @@ export var EventCenter = /*#__PURE__*/function () {
31
32
  */
32
33
  _createClass(EventCenter, [{
33
34
  key: "init",
34
- value: function init() {
35
+ value: function init(initOptions, instanceId, sdkMetaData) {
36
+ this.instanceId = instanceId;
35
37
  this.handleAppMessage = this.handleAppMessage.bind(this);
36
38
  window.addEventListener('message', this.handleAppMessage);
37
39
  registerSystemEvents(this);
@@ -70,6 +72,15 @@ export var EventCenter = /*#__PURE__*/function () {
70
72
  origin: getIframeOrigin(iframe)
71
73
  });
72
74
  }
75
+
76
+ /**
77
+ * Cleans iframes when web app close
78
+ */
79
+ }, {
80
+ key: "cleanIFrames",
81
+ value: function cleanIFrames() {
82
+ this.iframes = [];
83
+ }
73
84
  }, {
74
85
  key: "removeIFrame",
75
86
  value: function removeIFrame(iframe) {
@@ -89,7 +100,6 @@ export var EventCenter = /*#__PURE__*/function () {
89
100
  key: "handleAppMessage",
90
101
  value: function handleAppMessage(e) {
91
102
  var _e$data;
92
- // console.log('sdk received message:', e);
93
103
  if (!this.iframes.some(function (iframe) {
94
104
  return iframe.origin === e.origin;
95
105
  })) return;
@@ -98,15 +108,13 @@ export var EventCenter = /*#__PURE__*/function () {
98
108
  }
99
109
  var isJson = isJsonString(e.data);
100
110
  if (isJson) {
101
- var _eventPayload = JSON.parse(e.data);
102
- console.log('handleAppMessage', _eventPayload);
103
- if (_eventPayload.name !== MessageName.APP_TO_SDK) {
111
+ var eventPayload = JSON.parse(e.data);
112
+ if (eventPayload.name !== MessageName.APP_TO_SDK || eventPayload.instanceId !== this.instanceId) {
104
113
  return;
105
114
  }
106
- this._handleAppMessage(_eventPayload);
115
+ this._handleAppMessage(eventPayload);
107
116
  } else {
108
- console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
109
- // TODO: 异常上报
117
+ console.error(ERRORMESSAGE.NOT_JSON_FORMAT);
110
118
  }
111
119
  }
112
120
 
@@ -116,22 +124,24 @@ export var EventCenter = /*#__PURE__*/function () {
116
124
  */
117
125
  }, {
118
126
  key: "_handleAppMessage",
119
- value: function _handleAppMessage(eventPayload) {
120
- var context = eventPayload.context;
127
+ value: function _handleAppMessage(EventPayload) {
128
+ var context = EventPayload.context;
121
129
  var event = context.event,
122
130
  data = context.data;
123
- this.emit(event, data, eventPayload);
131
+ this.emit(event, data, EventPayload);
124
132
  }
125
133
 
126
134
  /**
127
135
  * Listens to an event by adding a callback function.
128
136
  * @param name - The name of the event to listen for.
129
137
  * @param func - The callback function to execute when the event is emitted.
138
+ * @param isAppend - Append to event handlers as chain, default value is false
130
139
  */
131
140
  }, {
132
141
  key: "listen",
133
142
  value: function listen(name, func) {
134
- var eventList = this.events.get(name) || [];
143
+ var isAppend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
144
+ var eventList = isAppend ? this.events.get(name) || [] : [];
135
145
  eventList.push({
136
146
  func: func
137
147
  });
@@ -166,11 +176,11 @@ export var EventCenter = /*#__PURE__*/function () {
166
176
  */
167
177
  }, {
168
178
  key: "emit",
169
- value: function emit(name, data, eventPayload) {
179
+ value: function emit(name, data, EventPayload) {
170
180
  if (this.events.has(name)) {
171
181
  var eventList = this.events.get(name);
172
182
  eventList.forEach(function (item) {
173
- item.func(data, eventPayload);
183
+ item.func(data, EventPayload);
174
184
  });
175
185
  }
176
186
  }
@@ -218,13 +228,13 @@ export var EventCenter = /*#__PURE__*/function () {
218
228
  _this = this;
219
229
  var data = {
220
230
  name: MessageName.SDK_TO_APP,
221
- context: payloadContext
231
+ context: payloadContext,
232
+ instanceId: this.instanceId
222
233
  };
223
- console.log('dispatchToApp');
224
234
  (_this$iframes = this.iframes) === null || _this$iframes === void 0 || _this$iframes.forEach(function (iframe) {
225
235
  var _iframe$origin;
226
236
  if (!iframe.ref.contentWindow) {
227
- console.warn('get app contentWindow error', iframe);
237
+ console.error('get app contentWindow error', iframe);
228
238
  return;
229
239
  }
230
240
  var _ref = _this.queryParse(iframe.ref.src) || {},
@@ -1,8 +1,8 @@
1
- import { IOptionsParams } from "../../../types";
1
+ import { IoptionsParams } from "../../../types";
2
2
  import { Service } from "../../index";
3
3
  export declare class GlobalDataService implements Service {
4
4
  private globalData;
5
- init(initOptions: IOptionsParams, instanceId: string): void;
5
+ init(initOptions: IoptionsParams, instanceId: string): void;
6
6
  destroy(): void;
7
7
  update(): void;
8
8
  getGlobalData(dataKey: string): any;
@@ -18,7 +18,7 @@ export var GlobalDataService = /*#__PURE__*/function () {
18
18
  var _this = this;
19
19
  // add capability to EventCenter
20
20
  var eventCenter = ServiceProvider.getInstance(instanceId).getService('EventCenter');
21
- eventCenter.listen(EVENT.getGlobalData.name, function (payload) {
21
+ eventCenter.listen(EVENT.getGlobalData.name, function (data, payload) {
22
22
  var _payload$context, _payload$context2, _payload$context3, _payload$context4;
23
23
  if (!((_payload$context = payload.context) !== null && _payload$context !== void 0 && _payload$context.eventCallbackId) || !((_payload$context2 = payload.context) !== null && _payload$context2 !== void 0 && (_payload$context2 = _payload$context2.data) !== null && _payload$context2 !== void 0 && _payload$context2.dataKey)) {
24
24
  return;
@@ -30,12 +30,11 @@ export var GlobalDataService = /*#__PURE__*/function () {
30
30
  data: targetData
31
31
  });
32
32
  });
33
- eventCenter.listen(EVENT.setGlobalData.name, function (payload) {
34
- var _payload$context5, _payload$context6, _payload$context$data, _payload$context$data2;
35
- if (!((_payload$context5 = payload.context) !== null && _payload$context5 !== void 0 && (_payload$context5 = _payload$context5.data) !== null && _payload$context5 !== void 0 && _payload$context5.dataKey) || !((_payload$context6 = payload.context) !== null && _payload$context6 !== void 0 && (_payload$context6 = _payload$context6.data) !== null && _payload$context6 !== void 0 && _payload$context6.data)) {
33
+ eventCenter.listen(EVENT.setGlobalData.name, function (data) {
34
+ if (!(data !== null && data !== void 0 && data.dataKey) || !(data !== null && data !== void 0 && data.data)) {
36
35
  return;
37
36
  }
38
- _this.globalData.set((_payload$context$data = payload.context.data) === null || _payload$context$data === void 0 ? void 0 : _payload$context$data.dataKey, (_payload$context$data2 = payload.context.data) === null || _payload$context$data2 === void 0 ? void 0 : _payload$context$data2.data);
37
+ _this.globalData.set(data.dataKey, data.data);
39
38
  });
40
39
 
41
40
  // register
@@ -1,4 +1,4 @@
1
- import { IOptionsParams } from '../../types';
1
+ import { IoptionsParams } from '../../types';
2
2
  import { PaymentContext, SDKMetaData, Service } from '../index';
3
3
  /**
4
4
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -12,7 +12,7 @@ export declare class ServiceProvider {
12
12
  private services;
13
13
  private extendServices;
14
14
  private constructor();
15
- init(initOptions: IOptionsParams, sdkMetaData: SDKMetaData): void;
15
+ init(initOptions: IoptionsParams, sdkMetaData: SDKMetaData): void;
16
16
  update(paymentContext: PaymentContext): void;
17
17
  getService<T>(serviceName: ServiceName): T;
18
18
  registerService(serviceName: string, service: Service): void;