@alipay/ams-checkout 0.0.1710212811-dev.9 → 0.0.1710748686-dev.2
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.
- package/dist/umd/ams-checkout.min.js +1 -1
- package/esm/common/applepay/index.d.ts +3 -5
- package/esm/common/applepay/index.js +20 -84
- package/esm/common/applepay/interface.d.ts +0 -61
- package/esm/common/applepay/interface.js +1 -73
- package/esm/constant/index.d.ts +2 -2
- package/esm/constant/index.js +4 -4
- package/esm/core/applepay/index.d.ts +1 -4
- package/esm/core/applepay/index.js +4 -13
- package/esm/core/component/index.d.ts +1 -7
- package/esm/core/component/index.js +17 -91
- package/esm/core/instance/index.d.ts +0 -1
- package/esm/core/instance/index.js +0 -2
- package/esm/plugin/component/index.js +12 -12
- package/esm/types/index.d.ts +2 -47
- package/esm/types/index.js +0 -8
- package/package.json +1 -1
- package/esm/core/bus/ability/sdk.d.ts +0 -9
- package/esm/core/bus/ability/sdk.js +0 -55
- package/esm/core/bus/index.d.ts +0 -63
- package/esm/core/bus/index.js +0 -287
- package/esm/core/bus/interface.d.ts +0 -24
- package/esm/core/bus/interface.js +0 -31
- package/esm/plugin/applepay/index.d.ts +0 -15
- package/esm/plugin/applepay/index.js +0 -99
@@ -30,7 +30,6 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
30
30
|
function AMSSDK(options) {
|
31
31
|
_classCallCheck(this, AMSSDK);
|
32
32
|
_defineProperty(this, "options", void 0);
|
33
|
-
_defineProperty(this, "originOptions", void 0);
|
34
33
|
_defineProperty(this, "logger", void 0);
|
35
34
|
_defineProperty(this, "_eventCenter", void 0);
|
36
35
|
_defineProperty(this, "_instanceId", void 0);
|
@@ -38,7 +37,6 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
38
37
|
_defineProperty(this, "securitySdkMap", void 0);
|
39
38
|
_defineProperty(this, "plugins", void 0);
|
40
39
|
this._instanceId = uuid();
|
41
|
-
this.originOptions = options;
|
42
40
|
this.options = {};
|
43
41
|
this._eventCenter = new EventCenter();
|
44
42
|
this._initEvent(options);
|
@@ -54,7 +54,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
54
54
|
_defineProperty(this, "_merchantAppointParam", void 0);
|
55
55
|
_defineProperty(this, "_webAppHeartBeatTimeoutId", void 0);
|
56
56
|
_defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
|
57
|
-
this._appVersion = '1.
|
57
|
+
this._appVersion = '1.13.0.0';
|
58
58
|
this._isInitComponent = false;
|
59
59
|
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
60
60
|
this.createIframeNode = function () {
|
@@ -364,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
364
364
|
this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
|
365
365
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
|
366
366
|
var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5;
|
367
|
-
var envInfo, params,
|
367
|
+
var envInfo, params, _this5$_renderParams$, extendInfo, enableVaultingApiOptimize, enableEasypayApiOptimize, extendInfoData, _this5$_renderParams6, _this5$_renderParams7, _ref3, _ref3$productSceneVer, productSceneVersion, _ref3$productScene, productScene, _ref4, _ref4$action, _ref4$action2, _ref4$action2$autoDeb, autoDebitWithToken, _this5$_renderParams8, _action$web, _action$wap, action, signType;
|
368
368
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
369
369
|
while (1) switch (_context2.prev = _context2.next) {
|
370
370
|
case 0:
|
@@ -380,7 +380,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
380
380
|
/**
|
381
381
|
* @description Simulated or unnecessary scenarios
|
382
382
|
*/
|
383
|
-
|
383
|
+
_this5$_renderParams$ = (_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData, extendInfo = _this5$_renderParams$.extendInfo;
|
384
384
|
enableVaultingApiOptimize = false;
|
385
385
|
enableEasypayApiOptimize = false;
|
386
386
|
try {
|
@@ -427,8 +427,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
427
427
|
_context2.next = 26;
|
428
428
|
break;
|
429
429
|
}
|
430
|
-
|
431
|
-
|
430
|
+
_ref3 = params.paymentSessionConfig || {}, _ref3$productSceneVer = _ref3.productSceneVersion, productSceneVersion = _ref3$productSceneVer === void 0 ? '' : _ref3$productSceneVer, _ref3$productScene = _ref3.productScene, productScene = _ref3$productScene === void 0 ? '' : _ref3$productScene;
|
431
|
+
_ref4 = ((_this5$_renderParams6 = _this5._renderParams) === null || _this5$_renderParams6 === void 0 ? void 0 : _this5$_renderParams6.paymentSessionMetaData) || {}, _ref4$action = _ref4.action, _ref4$action2 = _ref4$action === void 0 ? {} : _ref4$action, _ref4$action2$autoDeb = _ref4$action2.autoDebitWithToken, autoDebitWithToken = _ref4$action2$autoDeb === void 0 ? false : _ref4$action2$autoDeb;
|
432
432
|
if (!((_this5$_renderParams7 = _this5._renderParams) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.paymentSessionMetaData) !== null && _this5$_renderParams7 !== void 0 && (_this5$_renderParams7 = _this5$_renderParams7.action) !== null && _this5$_renderParams7 !== void 0 && _this5$_renderParams7.skipSdkQuery && enableEasypayApiOptimize)) {
|
433
433
|
_context2.next = 21;
|
434
434
|
break;
|
@@ -542,7 +542,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
542
542
|
|
543
543
|
// eslint-disable-next-line no-async-promise-executor
|
544
544
|
this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
|
545
|
-
var
|
545
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
|
546
546
|
var _this6$_renderParams;
|
547
547
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
548
548
|
while (1) switch (_context3.prev = _context3.next) {
|
@@ -605,7 +605,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
605
605
|
}, _callee3);
|
606
606
|
}));
|
607
607
|
return function (_x3) {
|
608
|
-
return
|
608
|
+
return _ref5.apply(this, arguments);
|
609
609
|
};
|
610
610
|
}());
|
611
611
|
}
|
@@ -975,10 +975,10 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
975
975
|
this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
|
976
976
|
return;
|
977
977
|
}
|
978
|
-
if (data.context.event === EVENT.
|
978
|
+
if (data.context.event === EVENT.sendMultiAppEventToSdk.name) {
|
979
979
|
this.dispatchToApp({
|
980
980
|
context: {
|
981
|
-
event: '
|
981
|
+
event: 'receiveMultiAppFromSdk',
|
982
982
|
data: data.context.data
|
983
983
|
}
|
984
984
|
});
|
@@ -1196,9 +1196,9 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
1196
1196
|
}
|
1197
1197
|
}, {
|
1198
1198
|
key: "handleDeclareInfo",
|
1199
|
-
value: function handleDeclareInfo(
|
1200
|
-
var
|
1201
|
-
closeDialogData =
|
1199
|
+
value: function handleDeclareInfo(_ref6) {
|
1200
|
+
var _ref6$closeDialogData = _ref6.closeDialogData,
|
1201
|
+
closeDialogData = _ref6$closeDialogData === void 0 ? {} : _ref6$closeDialogData;
|
1202
1202
|
_handleDeclareInfo({
|
1203
1203
|
closeDialogData: closeDialogData
|
1204
1204
|
});
|
package/esm/types/index.d.ts
CHANGED
@@ -135,17 +135,16 @@ export interface IpaymentSessionMetaData {
|
|
135
135
|
skipSdkQuery: boolean;
|
136
136
|
};
|
137
137
|
paymentSessionFactor?: {
|
138
|
-
|
138
|
+
applePay?: {
|
139
139
|
merchantCapabilities?: string[];
|
140
140
|
supportedNetworks?: string[];
|
141
141
|
};
|
142
142
|
merchantInfo?: {
|
143
143
|
registeredCountry?: string;
|
144
144
|
partnerId?: string;
|
145
|
-
merchantName?: string;
|
146
145
|
};
|
147
146
|
order?: {
|
148
|
-
orderDescription
|
147
|
+
orderDescription?: string;
|
149
148
|
};
|
150
149
|
paymentAmount?: {
|
151
150
|
value?: string;
|
@@ -157,43 +156,6 @@ export interface IpaymentSessionMetaData {
|
|
157
156
|
paymentMethodViewMetaData?: any;
|
158
157
|
paymentRequestId?: string;
|
159
158
|
supportedLanguages?: any;
|
160
|
-
/**
|
161
|
-
* 当前为苹果分期场景的信息
|
162
|
-
*/
|
163
|
-
recurringInfo?: {
|
164
|
-
/**
|
165
|
-
* 代扣协议开始日期 不传为当前系统时间
|
166
|
-
*/
|
167
|
-
startDate?: number;
|
168
|
-
/**
|
169
|
-
* 代扣协议结束日期 不传不限制结束时间
|
170
|
-
*/
|
171
|
-
endDate?: number;
|
172
|
-
/**
|
173
|
-
* 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
|
174
|
-
*/
|
175
|
-
intervalUnit?: string;
|
176
|
-
/**
|
177
|
-
* 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
|
178
|
-
*/
|
179
|
-
intervalCount?: number;
|
180
|
-
/**
|
181
|
-
* 分期标题信息
|
182
|
-
*/
|
183
|
-
title?: string;
|
184
|
-
/**
|
185
|
-
* 分期管理页面
|
186
|
-
*/
|
187
|
-
managementURL?: string;
|
188
|
-
/**
|
189
|
-
* 苹果通知ipay MAPN信息变更的地址
|
190
|
-
*/
|
191
|
-
tokenNotificationURL?: string;
|
192
|
-
/**
|
193
|
-
* 分期协议描述
|
194
|
-
*/
|
195
|
-
agreementDescription?: string;
|
196
|
-
};
|
197
159
|
};
|
198
160
|
}
|
199
161
|
export declare enum localeEnum {
|
@@ -471,11 +433,4 @@ export interface CallbackEventInfo {
|
|
471
433
|
export interface MultipleCallbackEvents {
|
472
434
|
[key: string]: CallbackEventInfo;
|
473
435
|
}
|
474
|
-
export declare enum PaymentMethodTypeEnum {
|
475
|
-
ApplePay = "ApplePay"
|
476
|
-
}
|
477
|
-
export declare enum ApplePaySubTypeEnum {
|
478
|
-
ApplePayRecurringPayment = "ApplePayRecurringPayment"
|
479
|
-
}
|
480
|
-
export type SubPaymentMethodTypeEnum = ApplePaySubTypeEnum;
|
481
436
|
export {};
|
package/esm/types/index.js
CHANGED
@@ -164,12 +164,4 @@ export var RedirectType = /*#__PURE__*/function (RedirectType) {
|
|
164
164
|
RedirectType["NormalUrl"] = "NormalUrl";
|
165
165
|
RedirectType["Unknown"] = "Unknown";
|
166
166
|
return RedirectType;
|
167
|
-
}({});
|
168
|
-
export var PaymentMethodTypeEnum = /*#__PURE__*/function (PaymentMethodTypeEnum) {
|
169
|
-
PaymentMethodTypeEnum["ApplePay"] = "ApplePay";
|
170
|
-
return PaymentMethodTypeEnum;
|
171
|
-
}({});
|
172
|
-
export var ApplePaySubTypeEnum = /*#__PURE__*/function (ApplePaySubTypeEnum) {
|
173
|
-
ApplePaySubTypeEnum["ApplePayRecurringPayment"] = "ApplePayRecurringPayment";
|
174
|
-
return ApplePaySubTypeEnum;
|
175
167
|
}({});
|
package/package.json
CHANGED
@@ -1,9 +0,0 @@
|
|
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
|
-
}
|
@@ -1,55 +0,0 @@
|
|
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
|
-
console.log("onEventCallback", message);
|
38
|
-
if (this._onEventCallback && data) {
|
39
|
-
this._onEventCallback(data);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}, {
|
43
|
-
key: "onMessage",
|
44
|
-
value: function onMessage(context, message) {
|
45
|
-
switch (message.getAction()) {
|
46
|
-
case SDKCallbackActionEnum.onEventCallback:
|
47
|
-
this.onEventCallback(message);
|
48
|
-
break;
|
49
|
-
default:
|
50
|
-
throw new Error("Unknown action: " + message.getAction());
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}]);
|
54
|
-
return SDKCallbackBusSubscriber;
|
55
|
-
}(BusSubscriber);
|
package/esm/core/bus/index.d.ts
DELETED
@@ -1,63 +0,0 @@
|
|
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
|
-
}
|
package/esm/core/bus/index.js
DELETED
@@ -1,287 +0,0 @@
|
|
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());
|
@@ -1,24 +0,0 @@
|
|
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
|
-
}
|