@alipay/ams-checkout 0.0.1710212811-dev.1 → 0.0.1710212811-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@
6
6
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
7
7
  */
8
8
  import { IGetMerchantSession, ICompletePaymentAuthorized, ICompleteApplePay, ILogError, IApplePayTrace } from './interface';
9
- import { IpaymentSessionMetaData } from '../../types';
9
+ import { ApplePaySubTypeEnum, IpaymentSessionMetaData } from '../../types';
10
10
  /**
11
11
  * Apple Pay Service
12
12
  */
@@ -19,7 +19,6 @@ declare class ApplePayService {
19
19
  private completeApplePay;
20
20
  private logError;
21
21
  private applePayTrace;
22
- private onEventCallback;
23
22
  constructor();
24
23
  /**
25
24
  * set Apple Pay Params
@@ -31,9 +30,11 @@ declare class ApplePayService {
31
30
  */
32
31
  setApplePayParams(getMerchantSession: IGetMerchantSession, completePaymentAuthorized: ICompletePaymentAuthorized, completeApplePay: ICompleteApplePay, logError: ILogError, applePayTrace: IApplePayTrace): void;
33
32
  /**
34
- * Apple Pay is enabled
33
+ * Is Apple Pay Enabled
34
+ * @param subTypeEnum
35
+ * @returns
35
36
  */
36
- isEnabled: () => boolean;
37
+ static canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): any;
37
38
  /**
38
39
  * has Active Card in Apple Pay
39
40
  * @param merchantIdentifier
@@ -17,6 +17,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
17
17
  */
18
18
  /* eslint-disable @typescript-eslint/no-explicit-any */
19
19
  import { APPLE_PAY_VERSION, APPLE_PAY_RECURRING_VERSION } from "./interface";
20
+ import { ApplePaySubTypeEnum } from "../../types";
21
+
20
22
  /**
21
23
  * Apple Pay Service
22
24
  */
@@ -32,13 +34,6 @@ var ApplePayService = /*#__PURE__*/function () {
32
34
  _defineProperty(this, "completeApplePay", void 0);
33
35
  _defineProperty(this, "logError", void 0);
34
36
  _defineProperty(this, "applePayTrace", void 0);
35
- _defineProperty(this, "onEventCallback", void 0);
36
- /**
37
- * Apple Pay is enabled
38
- */
39
- _defineProperty(this, "isEnabled", function () {
40
- return window.ApplePaySession ? window.ApplePaySession.canMakePayments() : false;
41
- });
42
37
  _defineProperty(this, "onvalidatemerchant", function (event) {
43
38
  _this.applePayTrace('onValidateMerchant');
44
39
  _this.getMerchantSession({
@@ -183,6 +178,12 @@ var ApplePayService = /*#__PURE__*/function () {
183
178
  this.logError = logError;
184
179
  this.applePayTrace = applePayTrace;
185
180
  }
181
+
182
+ /**
183
+ * Is Apple Pay Enabled
184
+ * @param subTypeEnum
185
+ * @returns
186
+ */
186
187
  }, {
187
188
  key: "hasActiveCard",
188
189
  value: (
@@ -215,6 +216,14 @@ var ApplePayService = /*#__PURE__*/function () {
215
216
  }
216
217
  return hasActiveCard;
217
218
  }())
219
+ }], [{
220
+ key: "canMakePayments",
221
+ value: function canMakePayments(subTypeEnum) {
222
+ if (ApplePaySubTypeEnum.ApplePayRecurringPayment === subTypeEnum) {
223
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
224
+ }
225
+ return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
226
+ }
218
227
  }]);
219
228
  return ApplePayService;
220
229
  }();
@@ -23,7 +23,7 @@ declare class ApplePayComponent extends CoreInstance {
23
23
  * @param subTypeEnum
24
24
  * @returns
25
25
  */
26
- canMakePayments(subTypeEnum: ApplePaySubTypeEnum): any;
26
+ canMakePayments(subTypeEnum?: ApplePaySubTypeEnum): boolean;
27
27
  /**
28
28
  * Submit Pay
29
29
  * @param paymentSessionData
@@ -28,12 +28,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
28
28
  * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
29
29
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
30
30
  */
31
- import { ApplePaySubTypeEnum, componentSignEnum, environmentEnum, eventCodeEnum, productSceneEnum } from "../../types";
31
+ import { componentSignEnum, environmentEnum, eventCodeEnum, productSceneEnum } from "../../types";
32
32
  import ApplePayService from "../../common/applepay";
33
33
  import { getComponentSign, parseSessionData } from "../component";
34
34
  import { getApplePayPaymentSession, submitPayInfo } from "../../service";
35
35
  import CoreInstance from "../instance";
36
- import { APPLE_PAY_RECURRING_VERSION, APPLE_PAY_VERSION } from "../../common/applepay/interface";
37
36
  import { EVENT } from "../../constant";
38
37
 
39
38
  /**
@@ -139,10 +138,7 @@ var ApplePayComponent = /*#__PURE__*/function (_CoreInstance) {
139
138
  }, {
140
139
  key: "canMakePayments",
141
140
  value: function canMakePayments(subTypeEnum) {
142
- if (ApplePaySubTypeEnum.ApplePayRecurringPayment === subTypeEnum) {
143
- return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_RECURRING_VERSION) : false;
144
- }
145
- return window.ApplePaySession ? window.ApplePaySession.canMakePayments() && window.ApplePaySession.supportsVersion(APPLE_PAY_VERSION) : false;
141
+ return ApplePayService.canMakePayments(subTypeEnum);
146
142
  }
147
143
 
148
144
  /**
@@ -0,0 +1,9 @@
1
+ import { BusContext, BusMessage, BusSubscriber } from "../index";
2
+ import { callOnEventCallback } from "../../../types";
3
+ export declare class SDKCallbackBusSubscriber extends BusSubscriber {
4
+ private _onEventCallback?;
5
+ constructor(onEventCallback?: callOnEventCallback);
6
+ actionNames(): string[];
7
+ protected onEventCallback(message: BusMessage): void;
8
+ onMessage(context: BusContext, message: BusMessage): void;
9
+ }
@@ -0,0 +1,54 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
9
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 "../interface";
16
+ import { BusSubscriber } from "../index";
17
+ export var SDKCallbackBusSubscriber = /*#__PURE__*/function (_BusSubscriber) {
18
+ _inherits(SDKCallbackBusSubscriber, _BusSubscriber);
19
+ var _super = _createSuper(SDKCallbackBusSubscriber);
20
+ function SDKCallbackBusSubscriber(onEventCallback) {
21
+ var _this;
22
+ _classCallCheck(this, SDKCallbackBusSubscriber);
23
+ _this = _super.call(this);
24
+ _defineProperty(_assertThisInitialized(_this), "_onEventCallback", void 0);
25
+ _this._onEventCallback = onEventCallback;
26
+ return _this;
27
+ }
28
+ _createClass(SDKCallbackBusSubscriber, [{
29
+ key: "actionNames",
30
+ value: function actionNames() {
31
+ return Object.values(SDKCallbackActionEnum);
32
+ }
33
+ }, {
34
+ key: "onEventCallback",
35
+ value: function onEventCallback(message) {
36
+ var data = message.getJSONObject();
37
+ if (this._onEventCallback && data) {
38
+ this._onEventCallback(data);
39
+ }
40
+ }
41
+ }, {
42
+ key: "onMessage",
43
+ value: function onMessage(context, message) {
44
+ switch (message.getAction()) {
45
+ case SDKCallbackActionEnum.onEventCallback:
46
+ this.onEventCallback(message);
47
+ break;
48
+ default:
49
+ throw new Error("Unknown action: " + message.getAction());
50
+ }
51
+ }
52
+ }]);
53
+ return SDKCallbackBusSubscriber;
54
+ }(BusSubscriber);
@@ -0,0 +1,63 @@
1
+ /**
2
+ * 扩展协议可序列化的消息定义
3
+ */
4
+ export declare class BusMessage {
5
+ private action;
6
+ private data;
7
+ private jsonData;
8
+ constructor(action: string, data: string);
9
+ getAction(): string;
10
+ getData(): string;
11
+ isJSONData(): boolean;
12
+ getJSONObject(): any;
13
+ private parseJSONData;
14
+ result(result: boolean): BusMessage;
15
+ }
16
+ export type OnBusCallback = (message: BusMessage) => void;
17
+ /**
18
+ * 扩展总线可选的Context参数,在Web端用于实时回调
19
+ */
20
+ export declare class BusContext {
21
+ private callback;
22
+ constructor(callback: OnBusCallback);
23
+ onCallBack(message: BusMessage): void;
24
+ }
25
+ /**
26
+ * 扩展能力的能力定义,基于此协议实现扩展能力
27
+ */
28
+ export declare abstract class BusSubscriber {
29
+ abstract actionNames(): string[];
30
+ abstract onMessage(context: BusContext, message: BusMessage): void;
31
+ }
32
+ /**
33
+ * 拦截器,可增加扩展性
34
+ */
35
+ export interface BusInterceptor {
36
+ /**
37
+ * 未订阅场景拦截
38
+ * @param actionName
39
+ */
40
+ onUnsubscribedAction?(actionName: string): boolean;
41
+ /**
42
+ * 分发消息场景处理异常
43
+ * @param message
44
+ */
45
+ onPublishException?(message: BusMessage, e: any): void;
46
+ }
47
+ /**
48
+ * 事件总线入口,支持的关系为:
49
+ * 发送者 和 接收者的关系: 一对一,大多数场景,支持callback
50
+ * 发送者 和 接收者的关系: 多对一, 设计上多一对,但是同一时间点,只会一个发送者,支持callback
51
+ * 发送者 和 接收者的关系: 一对多,可能有,埋点多重上报?不需要callback,业务场景应该是一个广播场景
52
+ */
53
+ export declare class BusManager {
54
+ private static interceptors;
55
+ private static subscribersMap;
56
+ static clear(): void;
57
+ static addInterceptor(interceptor: BusInterceptor): void;
58
+ static publishForResult(message: BusMessage, timeoutMs?: number): Promise<BusMessage>;
59
+ static publish(message: BusMessage, callback?: OnBusCallback): void;
60
+ static subscribe(subscriber: BusSubscriber): void;
61
+ static unsubscribe(subscriber: BusSubscriber): void;
62
+ static isSubscribed(actionName: string): boolean;
63
+ }
@@ -0,0 +1,287 @@
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 _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function (_e) { function e(_x) { return _e.apply(this, arguments); } e.toString = function () { return _e.toString(); }; return e; }(function (e) { throw e; }), f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ /**
12
+ * 扩展协议可序列化的消息定义
13
+ */
14
+ export var BusMessage = /*#__PURE__*/function () {
15
+ function BusMessage(action, data) {
16
+ _classCallCheck(this, BusMessage);
17
+ _defineProperty(this, "action", void 0);
18
+ _defineProperty(this, "data", void 0);
19
+ _defineProperty(this, "jsonData", null);
20
+ this.action = action;
21
+ this.data = data;
22
+ }
23
+ _createClass(BusMessage, [{
24
+ key: "getAction",
25
+ value: function getAction() {
26
+ return this.action;
27
+ }
28
+ }, {
29
+ key: "getData",
30
+ value: function getData() {
31
+ return this.data;
32
+ }
33
+ }, {
34
+ key: "isJSONData",
35
+ value: function isJSONData() {
36
+ this.parseJSONData();
37
+ return this.jsonData !== null;
38
+ }
39
+ }, {
40
+ key: "getJSONObject",
41
+ value: function getJSONObject() {
42
+ this.parseJSONData();
43
+ return this.jsonData;
44
+ }
45
+ }, {
46
+ key: "parseJSONData",
47
+ value: function parseJSONData() {
48
+ if (this.jsonData === null) {
49
+ try {
50
+ this.jsonData = JSON.parse(this.data);
51
+ } catch (e) {
52
+ // handle error if JSON parsing fails
53
+ this.jsonData = null;
54
+ }
55
+ }
56
+ }
57
+ }, {
58
+ key: "result",
59
+ value: function result(_result) {
60
+ return new BusMessage(this.action, JSON.stringify({
61
+ result: _result
62
+ }));
63
+ }
64
+ }]);
65
+ return BusMessage;
66
+ }();
67
+ /**
68
+ * 扩展总线可选的Context参数,在Web端用于实时回调
69
+ */
70
+ export var BusContext = /*#__PURE__*/function () {
71
+ function BusContext(callback) {
72
+ _classCallCheck(this, BusContext);
73
+ _defineProperty(this, "callback", void 0);
74
+ this.callback = callback;
75
+ }
76
+ _createClass(BusContext, [{
77
+ key: "onCallBack",
78
+ value: function onCallBack(message) {
79
+ if (this.callback) {
80
+ this.callback(message);
81
+ }
82
+ }
83
+ }]);
84
+ return BusContext;
85
+ }();
86
+
87
+ /**
88
+ * 扩展能力的能力定义,基于此协议实现扩展能力
89
+ */
90
+ export var BusSubscriber = /*#__PURE__*/_createClass(function BusSubscriber() {
91
+ _classCallCheck(this, BusSubscriber);
92
+ });
93
+
94
+ /**
95
+ * 拦截器,可增加扩展性
96
+ */
97
+
98
+ /**
99
+ * 事件总线入口,支持的关系为:
100
+ * 发送者 和 接收者的关系: 一对一,大多数场景,支持callback
101
+ * 发送者 和 接收者的关系: 多对一, 设计上多一对,但是同一时间点,只会一个发送者,支持callback
102
+ * 发送者 和 接收者的关系: 一对多,可能有,埋点多重上报?不需要callback,业务场景应该是一个广播场景
103
+ */
104
+ export var BusManager = /*#__PURE__*/function () {
105
+ function BusManager() {
106
+ _classCallCheck(this, BusManager);
107
+ }
108
+ _createClass(BusManager, null, [{
109
+ key: "clear",
110
+ value: function clear() {
111
+ BusManager.interceptors.length = 0;
112
+ BusManager.subscribersMap.clear();
113
+ }
114
+ }, {
115
+ key: "addInterceptor",
116
+ value: function addInterceptor(interceptor) {
117
+ if (!BusManager.interceptors.includes(interceptor)) {
118
+ BusManager.interceptors.push(interceptor);
119
+ }
120
+ }
121
+ }, {
122
+ key: "publishForResult",
123
+ value: function publishForResult(message) {
124
+ var _this = this;
125
+ var timeoutMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2000;
126
+ return new Promise(function (resolve, reject) {
127
+ _this.publish(message, function (result) {
128
+ resolve(result);
129
+ });
130
+ setTimeout(function () {
131
+ reject("publish timeout");
132
+ }, timeoutMs);
133
+ });
134
+ }
135
+ }, {
136
+ key: "publish",
137
+ value: function publish(message, callback) {
138
+ var context = new BusContext(callback);
139
+ var actionName = message.getAction();
140
+ var subscribers = BusManager.subscribersMap.get(actionName);
141
+ if (subscribers) {
142
+ var _iterator = _createForOfIteratorHelper(subscribers),
143
+ _step;
144
+ try {
145
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
146
+ var subscriber = _step.value;
147
+ try {
148
+ subscriber.onMessage(context, message);
149
+ } catch (e) {
150
+ var _iterator2 = _createForOfIteratorHelper(BusManager.interceptors),
151
+ _step2;
152
+ try {
153
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
154
+ var interceptor = _step2.value;
155
+ interceptor === null || interceptor === void 0 || interceptor.onPublishException(message, e);
156
+ }
157
+ } catch (err) {
158
+ _iterator2.e(err);
159
+ } finally {
160
+ _iterator2.f();
161
+ }
162
+ }
163
+ }
164
+ } catch (err) {
165
+ _iterator.e(err);
166
+ } finally {
167
+ _iterator.f();
168
+ }
169
+ } else {
170
+ var handle = false;
171
+ var _iterator3 = _createForOfIteratorHelper(BusManager.interceptors),
172
+ _step3;
173
+ try {
174
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
175
+ var _interceptor = _step3.value;
176
+ handle = handle || (_interceptor === null || _interceptor === void 0 ? void 0 : _interceptor.onUnsubscribedAction(message.getAction()));
177
+ }
178
+ } catch (err) {
179
+ _iterator3.e(err);
180
+ } finally {
181
+ _iterator3.f();
182
+ }
183
+ if (handle) {
184
+ BusManager.publish(message, callback); // Re-publish the message
185
+ } else {
186
+ // BusTraceUtils.notSubscribeMessage(message); // Implement this function as needed
187
+ }
188
+ }
189
+ }
190
+
191
+ // public static publish(message: BusMessage): void {
192
+ // const actionName = message.getAction();
193
+ // const subscribers = BusManager.subscribersMap.get(actionName);
194
+ // if (subscribers) {
195
+ // for (const subscriber of subscribers) {
196
+ // try {
197
+ // subscriber.onMessage(context, message);
198
+ // } catch (e) {
199
+ // // BusTraceUtils.sendMessageError(message, e); // Implement this function as needed
200
+ // }
201
+ // }
202
+ // } else {
203
+ // let handle = false;
204
+ // for (const interceptor of BusManager.interceptors) {
205
+ // handle = handle || interceptor.onUnsubscribedAction(message.getAction());
206
+ // }
207
+ // if (handle) {
208
+ // BusManager.publish(context, message); // Re-publish the message
209
+ // } else {
210
+ // // BusTraceUtils.notSubscribeMessage(message); // Implement this function as needed
211
+ // }
212
+ // }
213
+ // }
214
+ }, {
215
+ key: "subscribe",
216
+ value: function subscribe(subscriber) {
217
+ var _iterator4 = _createForOfIteratorHelper(subscriber.actionNames()),
218
+ _step4;
219
+ try {
220
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
221
+ var _actionName = _step4.value;
222
+ if (!BusManager.subscribersMap.has(_actionName)) {
223
+ BusManager.subscribersMap.set(_actionName, []);
224
+ }
225
+ var subscribers = BusManager.subscribersMap.get(_actionName);
226
+ if (subscribers && !subscribers.includes(subscriber)) {
227
+ subscribers.push(subscriber);
228
+ }
229
+ }
230
+ } catch (err) {
231
+ _iterator4.e(err);
232
+ } finally {
233
+ _iterator4.f();
234
+ }
235
+ }
236
+ }, {
237
+ key: "unsubscribe",
238
+ value: function unsubscribe(subscriber) {
239
+ var _iterator5 = _createForOfIteratorHelper(subscriber.actionNames()),
240
+ _step5;
241
+ try {
242
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
243
+ var _actionName2 = _step5.value;
244
+ var subscribers = BusManager.subscribersMap.get(_actionName2);
245
+ if (subscribers) {
246
+ var index = subscribers.indexOf(subscriber);
247
+ if (index !== -1) {
248
+ subscribers.splice(index, 1);
249
+ }
250
+ }
251
+ }
252
+ } catch (err) {
253
+ _iterator5.e(err);
254
+ } finally {
255
+ _iterator5.f();
256
+ }
257
+ }
258
+ }, {
259
+ key: "isSubscribed",
260
+ value: function isSubscribed(actionName) {
261
+ var subscribers = BusManager.subscribersMap.get(actionName);
262
+ if (subscribers && subscribers.length > 0) {
263
+ return true;
264
+ }
265
+ var handle = false;
266
+ var _iterator6 = _createForOfIteratorHelper(BusManager.interceptors),
267
+ _step6;
268
+ try {
269
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
270
+ var interceptor = _step6.value;
271
+ handle = handle || interceptor.onUnsubscribedAction(actionName);
272
+ }
273
+ } catch (err) {
274
+ _iterator6.e(err);
275
+ } finally {
276
+ _iterator6.f();
277
+ }
278
+ if (handle) {
279
+ return BusManager.subscribersMap.has(actionName);
280
+ }
281
+ return false;
282
+ }
283
+ }]);
284
+ return BusManager;
285
+ }();
286
+ _defineProperty(BusManager, "interceptors", []);
287
+ _defineProperty(BusManager, "subscribersMap", new Map());
@@ -0,0 +1,24 @@
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
+ destoryComponent = "plugin_CARD_APPLE_PAY_destoryComponent"
8
+ }
9
+ export declare enum SDKCallbackActionEnum {
10
+ onEventCallback = "onEventCallback"
11
+ }
12
+ export declare enum ComponentActiontEnum {
13
+ onDestory = "onDestory"
14
+ }
15
+ export declare enum RequestActiontEnum {
16
+ onDestory = "httpRequest"
17
+ }
18
+ export declare enum MonitorActiontEnum {
19
+ reportAnalytics = "reportAnalytics"
20
+ }
21
+ export declare enum LoadingActiontEnum {
22
+ showLoading = "showLoading",
23
+ dismissLoading = "dismissLoading"
24
+ }
@@ -0,0 +1,31 @@
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["destoryComponent"] = "plugin_CARD_APPLE_PAY_destoryComponent";
9
+ return ApplePayActionEnum;
10
+ }({});
11
+ export var SDKCallbackActionEnum = /*#__PURE__*/function (SDKCallbackActionEnum) {
12
+ SDKCallbackActionEnum["onEventCallback"] = "onEventCallback";
13
+ return SDKCallbackActionEnum;
14
+ }({});
15
+ export var ComponentActiontEnum = /*#__PURE__*/function (ComponentActiontEnum) {
16
+ ComponentActiontEnum["onDestory"] = "onDestory";
17
+ return ComponentActiontEnum;
18
+ }({});
19
+ export var RequestActiontEnum = /*#__PURE__*/function (RequestActiontEnum) {
20
+ RequestActiontEnum["onDestory"] = "httpRequest";
21
+ return RequestActiontEnum;
22
+ }({});
23
+ export var MonitorActiontEnum = /*#__PURE__*/function (MonitorActiontEnum) {
24
+ MonitorActiontEnum["reportAnalytics"] = "reportAnalytics";
25
+ return MonitorActiontEnum;
26
+ }({});
27
+ export var LoadingActiontEnum = /*#__PURE__*/function (LoadingActiontEnum) {
28
+ LoadingActiontEnum["showLoading"] = "showLoading";
29
+ LoadingActiontEnum["dismissLoading"] = "dismissLoading";
30
+ return LoadingActiontEnum;
31
+ }({});
@@ -1,5 +1,5 @@
1
1
  import ComponentApp from '../../plugin/component';
2
- import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit } from '../../types';
2
+ import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
3
3
  import CoreInstance from '../instance/index';
4
4
  export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
5
5
  export declare const parseSessionData: (sessionData: string) => [IpaymentSessionMetaData, string];
@@ -11,11 +11,17 @@ export declare class AMSComponent extends CoreInstance {
11
11
  private parameterInitAndCheck;
12
12
  private pluginAppendIframe;
13
13
  private savePreviousChannel;
14
+ /**
15
+ * 初始化 Bus总线的能力
16
+ */
17
+ private registerBusAbility;
18
+ canMakePayments(paymentMethod: PaymentMethodTypeEnum, subPaymentMethod: SubPaymentMethodTypeEnum): Promise<boolean>;
14
19
  /**
15
20
  * @description Create component application
16
21
  * @param params - The data source created by the component, necessary sessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
17
22
  */
18
23
  createComponent(params: IcreateComponent): Promise<void>;
24
+ isApplePay(paymentSessionData: string): boolean;
19
25
  preloadComponent(channelType: any, productSceneVersion: any): void;
20
26
  clearPreloadIframe(isTimeOut?: boolean): void;
21
27
  /**