@alipay/ams-checkout 0.0.1730107332-dev.3 → 0.0.1730107332-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.
@@ -64,7 +64,7 @@ export var AntomSDKCore = /*#__PURE__*/function () {
64
64
  var _this = this;
65
65
  var eventCenter = ServiceProvider.getInstance(this.instanceId).getService('EventCenter');
66
66
  eventCenter.listen(EVENT.redirect.name, function (data) {
67
- var _data$isDestroy;
67
+ var _data$isDestroy, _data$isCallApp, _data$callAppDetectSu;
68
68
  if (!data) {
69
69
  return;
70
70
  }
@@ -75,7 +75,9 @@ export var AntomSDKCore = /*#__PURE__*/function () {
75
75
  applinkUrl: (data === null || data === void 0 ? void 0 : data.applinkUrl) || '',
76
76
  schemeUrl: (data === null || data === void 0 ? void 0 : data.schemeUrl) || '',
77
77
  url: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
78
- browserLinkTarget: data === null || data === void 0 ? void 0 : data.target
78
+ browserLinkTarget: data === null || data === void 0 ? void 0 : data.target,
79
+ isCallApp: (_data$isCallApp = data === null || data === void 0 ? void 0 : data.isCallApp) !== null && _data$isCallApp !== void 0 ? _data$isCallApp : false,
80
+ callAppDetectSuccessDelay: (_data$callAppDetectSu = data === null || data === void 0 ? void 0 : data.callAppDetectSuccessDelay) !== null && _data$callAppDetectSu !== void 0 ? _data$callAppDetectSu : 5000
79
81
  };
80
82
  redirect(redirectBehavior, _this.instanceId);
81
83
  if (needCleanContainer) {
@@ -19,6 +19,7 @@ export interface StartBizFlowOptions {
19
19
  paymentSession: string;
20
20
  displayInfo?: Partial<DisplayInfo>;
21
21
  submitPayRequestExtra?: any;
22
+ isAppWebview?: boolean;
22
23
  }
23
24
  export declare class DisplayInfo {
24
25
  type: DisplayTypeEnum;
@@ -50,6 +51,8 @@ export interface RedirectBehaviorPayload {
50
51
  schemeUrl?: string;
51
52
  applinkUrl?: string;
52
53
  browserLinkTarget?: TargetEnum;
54
+ isCallApp?: boolean;
55
+ callAppDetectSuccessDelay?: number;
53
56
  }
54
57
  /**
55
58
  * Provide some capability, such as MonitorService, EventBusService, SecurityService
@@ -6,6 +6,7 @@ export { ProductInfoCacheUtil } from '../../utils/payment_product_utils';
6
6
  export { v4 as uuid } from 'uuid';
7
7
  export type { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, CashierSubmitPayRequest, CashierSubmitPayResult, IOptionsParams, } from '../../../types';
8
8
  export { isPC } from '../../../util';
9
+ export { getBackScheme } from '../../../util/getBackScheme';
9
10
  export { isLocalMock } from '../../../util/mock';
10
11
  export type { BizFlowStartBehavior, PaymentContext, ProductProcessor, RedirectBehaviorPayload, RenderBehaviorPayload } from '../..';
11
12
  export { ServiceProvider } from '../../service';
@@ -4,6 +4,7 @@ export { DisplayTypeEnum, PaymentMethodCategoryTypeEnum, ProductSceneEnum } from
4
4
  export { ProductInfoCacheUtil } from "../../utils/payment_product_utils";
5
5
  export { v4 as uuid } from 'uuid';
6
6
  export { isPC } from "../../../util";
7
+ export { getBackScheme } from "../../../util/getBackScheme";
7
8
  export { isLocalMock } from "../../../util/mock";
8
9
  export { ServiceProvider } from "../../service";
9
10
  export { LogService } from "../../service/log";
@@ -16,7 +16,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
16
16
  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; }
17
17
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
18
  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); }
19
- import { uuid, ProductSceneEnum, ChannelCustomize, DisplayTypeEnum, isLocalMock, isPC, ServiceProvider, ProductInfoCacheUtil, WebAppUrlUtil } from "./deps";
19
+ import { ChannelCustomize, DisplayTypeEnum, getBackScheme, isLocalMock, isPC, ProductInfoCacheUtil, ProductSceneEnum, ServiceProvider, uuid, WebAppUrlUtil } from "./deps";
20
20
  export var EasySafePayProcessor = /*#__PURE__*/function () {
21
21
  function EasySafePayProcessor() {
22
22
  _classCallCheck(this, EasySafePayProcessor);
@@ -242,6 +242,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
242
242
  renderDisplayType: _this2.paymentContext.displayInfo.type,
243
243
  appearance: (_this2$paymentContext3 = _this2.paymentContext.displayInfo) === null || _this2$paymentContext3 === void 0 ? void 0 : _this2$paymentContext3.appearance,
244
244
  notRedirectAfterComplete: ((_this2$paymentContext4 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext4 === void 0 ? void 0 : _this2$paymentContext4.notRedirectAfterComplete) === true,
245
+ isAppWebview: _this2.paymentContext.startBizFlowOptions.isAppWebview,
245
246
  merchantAppointParam: (_this2$paymentContext5 = _this2.paymentContext.startBizFlowOptions.submitPayRequestExtra) === null || _this2$paymentContext5 === void 0 ? void 0 : _this2$paymentContext5.merchantAppointParam,
246
247
  allowSubmitPayCallAhead: _this2.allowSubmitPayCallAhead,
247
248
  envInfo: {
@@ -387,8 +388,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
387
388
  key: "processSubmitPay",
388
389
  value: function () {
389
390
  var _processSubmitPay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
390
- var _this$paymentContext6, _this$paymentContext7, _this$paymentContext9, _this$channelBehavior3, _this$channelBehavior4, _this$paymentContext$;
391
- var submitParams, shouldSkipSubmitPayInSDK, _this$paymentContext8, _ref5, _ref5$productSceneVer, productSceneVersion, _ref6, _ref6$action, _ref6$action2, _ref6$action2$enableS, enableSignAgreement, _ref6$action2$autoDeb, autoDebitWithToken, requestBizId, extParams, requester, res;
391
+ var _this$paymentContext6, _this$paymentContext7, _this$paymentContext9, _this$channelBehavior3, _this$channelBehavior4, _this$paymentContext$2;
392
+ var submitParams, shouldSkipSubmitPayInSDK, _this$paymentContext8, _ref5, _ref5$productSceneVer, productSceneVersion, _ref6, _ref6$action, _ref6$action2, _ref6$action2$enableS, enableSignAgreement, _ref6$action2$autoDeb, autoDebitWithToken, _this$paymentContext$, paymentMethodType, isAppWebview, backScheme, requestBizId, extParams, requester, res;
392
393
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
393
394
  while (1) switch (_context3.prev = _context3.next) {
394
395
  case 0:
@@ -410,6 +411,14 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
410
411
  if (productSceneVersion === '2.0' && !autoDebitWithToken) {
411
412
  ///EasyPay 2.0 首次传signAgreement字段
412
413
  submitParams['signAgreement'] = enableSignAgreement;
414
+ paymentMethodType = (_this$paymentContext$ = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$ === void 0 || (_this$paymentContext$ = _this$paymentContext$.paymentMethodInfoView) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.paymentMethodType;
415
+ isAppWebview = this.paymentContext.startBizFlowOptions.isAppWebview;
416
+ if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
417
+ backScheme = getBackScheme(undefined, this.logger);
418
+ if (backScheme && backScheme !== 'https') {
419
+ submitParams['h5FromApp'] = encodeURIComponent(backScheme);
420
+ }
421
+ }
413
422
  }
414
423
  // 带上标记告知WebCheckOut SDK已发送submitpay请求
415
424
  this.allowSubmitPayCallAhead = !shouldSkipSubmitPayInSDK;
@@ -433,7 +442,7 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
433
442
  extParams = ((_this$channelBehavior3 = this.channelBehavior) === null || _this$channelBehavior3 === void 0 || (_this$channelBehavior4 = _this$channelBehavior3.buildSubmitPayExtParams) === null || _this$channelBehavior4 === void 0 ? void 0 : _this$channelBehavior4.call(_this$channelBehavior3, {
434
443
  instanceId: this.instanceId,
435
444
  locale: this.initConfig.locale,
436
- paymentMethodType: (_this$paymentContext$ = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$ === void 0 || (_this$paymentContext$ = _this$paymentContext$.paymentMethodInfoView) === null || _this$paymentContext$ === void 0 ? void 0 : _this$paymentContext$.paymentMethodType,
445
+ paymentMethodType: (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentMethodInfoView) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.paymentMethodType,
437
446
  paymentSessionData: this.paymentContext.paymentSession,
438
447
  env: this.initConfig.environment,
439
448
  sdkVersion: this.paymentContext.sdkMetaData.sdkVersion
@@ -499,13 +508,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
499
508
  key: "acquireApdidToken",
500
509
  value: function () {
501
510
  var _acquireApdidToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
502
- var _this$paymentContext$2;
511
+ var _this$paymentContext$3;
503
512
  var securityService, productScene, deviceId;
504
513
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
505
514
  while (1) switch (_context4.prev = _context4.next) {
506
515
  case 0:
507
516
  securityService = ServiceProvider.getInstance(this.instanceId).getService('Security');
508
- productScene = (_this$paymentContext$2 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$2 === void 0 || (_this$paymentContext$2 = _this$paymentContext$2.paymentSessionConfig) === null || _this$paymentContext$2 === void 0 ? void 0 : _this$paymentContext$2.productScene;
517
+ productScene = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj) === null || _this$paymentContext$3 === void 0 || (_this$paymentContext$3 = _this$paymentContext$3.paymentSessionConfig) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.productScene;
509
518
  deviceId = securityService.getDeviceId({
510
519
  productScene: productScene
511
520
  });
@@ -525,13 +534,13 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
525
534
  key: "initSecuritySDK",
526
535
  value: function () {
527
536
  var _initSecuritySDK = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
528
- var _this$paymentContext$3, productSceneVersion, nonCompliant, isFirstTimeToPay;
537
+ var _this$paymentContext$4, productSceneVersion, nonCompliant, isFirstTimeToPay;
529
538
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
530
539
  while (1) switch (_context5.prev = _context5.next) {
531
540
  case 0:
532
541
  _context5.prev = 0;
533
542
  productSceneVersion = this.paymentContext.paymentSessionObj.paymentSessionConfig.productSceneVersion;
534
- nonCompliant = (_this$paymentContext$3 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$3 === void 0 ? void 0 : _this$paymentContext$3.nonCompliant;
543
+ nonCompliant = (_this$paymentContext$4 = this.paymentContext.paymentSessionObj.action) === null || _this$paymentContext$4 === void 0 ? void 0 : _this$paymentContext$4.nonCompliant;
535
544
  isFirstTimeToPay = !this.paymentContext.paymentSessionObj.action.autoDebitWithToken;
536
545
  if (!(productSceneVersion === '1.0')) {
537
546
  _context5.next = 9;
@@ -54,7 +54,6 @@ export var ContainerService = /*#__PURE__*/function () {
54
54
  }, {
55
55
  key: "load",
56
56
  value: function load(displayInfo, url, closeBtnFunc) {
57
- console.log('load');
58
57
  var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(displayInfo.selector) : ''));
59
58
  this.webApp = webApp;
60
59
  this.displayInfo = displayInfo;
@@ -20,15 +20,31 @@ export var redirect = function redirect(payload, instanceId) {
20
20
  logService.logInfo({
21
21
  title: 'sdk_event_call_url_start'
22
22
  }, _objectSpread({}, payload)).send();
23
+ if (payload.isCallApp && payload.schemeUrl) {
24
+ var detectSuccessDelay = payload.callAppDetectSuccessDelay;
25
+ var _callAppLib = new CallApp({
26
+ successCb: function successCb() {
27
+ successCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
28
+ },
29
+ resultJudgmentTime: detectSuccessDelay
30
+ });
31
+ _callAppLib.open({
32
+ scheme: payload.schemeUrl,
33
+ fallback: function fallback() {
34
+ failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
35
+ }
36
+ });
37
+ return;
38
+ }
23
39
  // 支持 target: _blank,新开tab页打开
24
40
  if (payload.browserLinkTarget === TargetEnum.BLANK) {
25
- if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', payload, serviceProvider);
41
+ if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
26
42
  successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
27
43
  window.open(payload.url);
28
44
  return;
29
45
  }
30
46
  if (payload.browserLinkTarget === TargetEnum.REPLACE && !(payload !== null && payload !== void 0 && payload.applinkUrl) && !(payload !== null && payload !== void 0 && payload.schemeUrl)) {
31
- if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', payload, serviceProvider);
47
+ if (!payload.url) return failCallback(payload, RedirectType.NormalUrl, '', serviceProvider);
32
48
  successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
33
49
  window.location.replace(payload.url);
34
50
  return;
@@ -55,14 +71,14 @@ export var redirect = function redirect(payload, instanceId) {
55
71
  fallback: function fallback() {
56
72
  // Applink evoke failed, try to use scheme url
57
73
  if (payload.applinkUrl) {
58
- failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, payload, serviceProvider);
74
+ failCallback(payload, RedirectType.ApplinkUrl, payload.applinkUrl, serviceProvider);
59
75
  }
60
76
  callAppLib.open({
61
77
  scheme: payload.schemeUrl,
62
78
  fallback: function fallback() {
63
79
  // SchemeUrl evoke failed
64
80
  if (payload.schemeUrl) {
65
- failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, payload, serviceProvider);
81
+ failCallback(payload, RedirectType.SchemeUrl, payload.schemeUrl, serviceProvider);
66
82
  }
67
83
  window.location.href = payload.url;
68
84
  successCallback(payload, RedirectType.NormalUrl, payload.url, serviceProvider);
@@ -84,10 +100,10 @@ var successCallback = function successCallback(payload, type, url, serviceProvid
84
100
  url: url
85
101
  }).send();
86
102
  };
87
- var failCallback = function failCallback(payload, type, url, behaviorData, serviceProvider) {
103
+ var failCallback = function failCallback(payload, type, url, serviceProvider) {
88
104
  serviceProvider.getService('EventCenter').emit(EVENT.eventCallback.name, {
89
105
  code: eventCodeEnum.SDK_CALL_URL_ERROR,
90
- message: "Failed to open app,applinkUrl: ".concat(behaviorData === null || behaviorData === void 0 ? void 0 : behaviorData.applinkUrl, " schemeUrl: ").concat(behaviorData === null || behaviorData === void 0 ? void 0 : behaviorData.schemeUrl, " normalUrl: ").concat(behaviorData === null || behaviorData === void 0 ? void 0 : behaviorData.url)
106
+ message: "Failed to open app,applinkUrl: ".concat(payload === null || payload === void 0 ? void 0 : payload.applinkUrl, " schemeUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.schemeUrl, " normalUrl: ").concat(payload === null || payload === void 0 ? void 0 : payload.url)
91
107
  });
92
108
  serviceProvider.getService('Log').logInfo({
93
109
  title: 'sdk_error_call_url_failed'
package/esm/index.js CHANGED
@@ -37,7 +37,8 @@ export var AMSEasyPay = /*#__PURE__*/function () {
37
37
  paymentSession: params.sessionData || params.paymentSessionData,
38
38
  displayInfo: {
39
39
  type: DisplayTypeEnum.popup
40
- }
40
+ },
41
+ isAppWebview: params.isAppWebview
41
42
  });
42
43
  }
43
44
  }]);
@@ -106,25 +106,8 @@ export interface IcreateComponent {
106
106
  accentColor?: string;
107
107
  };
108
108
  merchantAppointParam?: IMerchantAppointParam;
109
+ isAppWebview?: boolean;
109
110
  }
110
- export interface IappendIframeNodesParams extends IcreateComponent {
111
- paymentSessionMetaData: IPaymentSessionMetaData;
112
- renderDisplayType: DisplayTypeEnum;
113
- selector?: Iselector;
114
- paypalConfiguration?: IPaypalConfiguration;
115
- connectFactor?: {
116
- enableConnect: boolean;
117
- };
118
- /** 将address-element参数定义合入原参数定义 */
119
- configParams?: {
120
- hideFields?: string[];
121
- addressAutoSuggestDisabled?: addressAutoSuggestDisabledType;
122
- };
123
- prefillValue?: AddressItem[];
124
- componentSession?: string;
125
- loca?: string;
126
- }
127
- /** 表单地址数据 */
128
111
  export interface AddressItem {
129
112
  shippingName: {
130
113
  firstName: string;
@@ -167,7 +150,6 @@ export interface AddressItem {
167
150
  prefer?: '1' | '0';
168
151
  shippingId?: string;
169
152
  }
170
- type addressAutoSuggestDisabledType = 0 | 1;
171
153
  export interface IPaypalConfiguration {
172
154
  style?: object;
173
155
  blockPayPalCreditButton?: boolean;
@@ -655,10 +637,6 @@ export declare enum ProductSceneVersion {
655
637
  V1 = "1.0",
656
638
  V2 = "2.0"
657
639
  }
658
- export type IAppendParams = {
659
- componentSign: ComponentSignEnum;
660
- iframeNodesParams: IappendIframeNodesParams;
661
- };
662
640
  export declare enum EventCallbackCode {
663
641
  Failed = "Failed",
664
642
  Completed = "Completed"
@@ -56,9 +56,6 @@ export var PaymentMethodCategoryTypeEnum = /*#__PURE__*/function (PaymentMethodC
56
56
  PaymentMethodCategoryTypeEnum["ALL"] = "ALL";
57
57
  return PaymentMethodCategoryTypeEnum;
58
58
  }({});
59
-
60
- /** 表单地址数据 */
61
-
62
59
  export var payPalConfigurationIntentEnum = /*#__PURE__*/function (payPalConfigurationIntentEnum) {
63
60
  payPalConfigurationIntentEnum["intent"] = "intent";
64
61
  payPalConfigurationIntentEnum["capture"] = "capture";
@@ -0,0 +1,5 @@
1
+ import { LogService } from "../foundation/service/log";
2
+ /**
3
+ * 通过配置规则检测 UA 和获得回跳 scheme
4
+ */
5
+ export declare function getBackScheme(mockUa?: string, logger?: LogService): any;
@@ -0,0 +1,134 @@
1
+ var RULES = [{
2
+ matchRule: 'AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z]+) Safari\\/([0-9\\._]+)$',
3
+ iosScheme: 'https',
4
+ andScheme: ''
5
+ }, {
6
+ matchRule: 'HeyTapBrowser',
7
+ iosScheme: '',
8
+ andScheme: ''
9
+ }, {
10
+ matchRule: 'HuaweiBrowser',
11
+ iosScheme: '',
12
+ andScheme: ''
13
+ }, {
14
+ matchRule: 'Kwai',
15
+ iosScheme: 'kwai',
16
+ andScheme: ''
17
+ }, {
18
+ matchRule: 'MQQBrowser',
19
+ iosScheme: 'mttbrowser',
20
+ andScheme: ''
21
+ }, {
22
+ matchRule: 'MicroMessenger',
23
+ iosScheme: '',
24
+ andScheme: ''
25
+ }, {
26
+ matchRule: 'MiuiBrowser',
27
+ iosScheme: '',
28
+ andScheme: ''
29
+ }, {
30
+ matchRule: 'Mozilla\\/([0-9\\.]+).* AppleWebKit\\/([0-9\\.]+).* CriOS\\/([0-9\\._]+) Mobile\\/([0-9\\._A-Z\\._a-z]+) Safari\\/([0-9\\._]+)$',
31
+ iosScheme: 'googlechrome',
32
+ andScheme: ''
33
+ }, {
34
+ matchRule: 'Mozilla\\/([0-9\\.]+).* AppleWebKit\\/([0-9\\.]+).* Version\\/([0-9\\._]+) Mobile Safari\\/([0-9\\._]+)$',
35
+ iosScheme: 'googlechrome',
36
+ andScheme: ''
37
+ }, {
38
+ matchRule: 'NewsArticle',
39
+ iosScheme: 'snssdk141',
40
+ andScheme: ''
41
+ }, {
42
+ matchRule: 'UCBrowser',
43
+ iosScheme: 'ucbrowser',
44
+ andScheme: ''
45
+ }, {
46
+ matchRule: 'VideoArticle',
47
+ iosScheme: 'snssdk32',
48
+ andScheme: ''
49
+ }, {
50
+ matchRule: 'VivoBrowser',
51
+ iosScheme: '',
52
+ andScheme: ''
53
+ }, {
54
+ matchRule: 'ZhongAnWebView',
55
+ iosScheme: 'zaapp',
56
+ andScheme: ''
57
+ }, {
58
+ matchRule: 'aweme',
59
+ iosScheme: 'snssdk1128',
60
+ andScheme: ''
61
+ }, {
62
+ matchRule: 'aweme_lite',
63
+ iosScheme: 'snssdk2329',
64
+ andScheme: ''
65
+ }, {
66
+ matchRule: 'com.xs.fm',
67
+ iosScheme: 'novelfm3040',
68
+ andScheme: ''
69
+ }, {
70
+ matchRule: 'netdisk',
71
+ iosScheme: '',
72
+ andScheme: ''
73
+ }, {
74
+ matchRule: 'qqnews',
75
+ iosScheme: 'qqnews',
76
+ andScheme: ''
77
+ }];
78
+
79
+ /**
80
+ * 通过配置规则检测 UA 和获得回跳 scheme
81
+ */
82
+ export function getBackScheme(mockUa, logger) {
83
+ var ua = mockUa || window.navigator.userAgent || '';
84
+ // 获取规则
85
+ var uaMatchedRule = RULES;
86
+ var matchedRule;
87
+ var matched = null;
88
+ for (var i = 0; i < uaMatchedRule.length; i++) {
89
+ var rule = uaMatchedRule[i];
90
+ matched = ua.match(rule.matchRule);
91
+ if (matched) {
92
+ matchedRule = rule;
93
+ break;
94
+ }
95
+ }
96
+ if (!matchedRule) {
97
+ logBackScheme(logger, ua, '');
98
+ return;
99
+ }
100
+ if (isAndroid(ua)) {
101
+ logBackScheme(logger, ua, matchedRule.andScheme);
102
+ return matchedRule.andScheme;
103
+ }
104
+ if (isIOS(ua)) {
105
+ logBackScheme(logger, ua, matchedRule.iosScheme);
106
+ return matchedRule.iosScheme;
107
+ }
108
+ }
109
+ function logBackScheme(logger, userAgent, scheme) {
110
+ if (logger) {
111
+ logger.logInfo({
112
+ title: 'a3753.b101271.c377460'
113
+ }, {
114
+ userAgent: userAgent,
115
+ backScheme: scheme
116
+ });
117
+ }
118
+ }
119
+
120
+ /**
121
+ * 当前运行环境是否 Android
122
+ */
123
+ function isAndroid(mockUA) {
124
+ var ua = (mockUA || navigator.userAgent).toLowerCase();
125
+ return /android|adr|linux/.test(ua);
126
+ }
127
+
128
+ /**
129
+ * 当前运行环境是否 IOS
130
+ */
131
+ function isIOS(mockUA) {
132
+ var ua = (mockUA || navigator.userAgent).toLowerCase();
133
+ return /iphone|ipad|ipod|ios|macintosh/.test(ua);
134
+ }
@@ -4,16 +4,6 @@
4
4
  * 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
5
5
  * 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.
6
6
  */
7
- declare class EventCenter {
8
- private events;
9
- private eventsKey;
10
- constructor();
11
- on(name: string, func: any, key?: string): void;
12
- off(name: string, func: any, key?: string): void;
13
- emit(name: string, ...rest: any): void;
14
- once(name: string, func: any, key?: string): void;
15
- isExist(name: string): boolean;
16
- }
17
7
  declare const getType: (target: any) => string;
18
8
  declare const getViewPort: (key: string) => any;
19
9
  declare const getOrigin: () => string;
@@ -46,4 +36,4 @@ declare function loadSDKScript({ src, attrOptions, timeOut, loadCallback }: {
46
36
  timeOut?: number;
47
37
  loadCallback?: any;
48
38
  }, logger: any): Promise<unknown>;
49
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, };
39
+ export { getType, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript, };
package/esm/util/index.js CHANGED
@@ -1,10 +1,4 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _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 _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; }
6
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
- 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); }
8
2
  /**
9
3
  * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
10
4
  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@@ -12,81 +6,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
12
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.
13
7
  */
14
8
  /* eslint-disable @typescript-eslint/no-explicit-any */
15
- var EventCenter = /*#__PURE__*/function () {
16
- function EventCenter() {
17
- _classCallCheck(this, EventCenter);
18
- _defineProperty(this, "events", void 0);
19
- _defineProperty(this, "eventsKey", void 0);
20
- this.events = new Map();
21
- this.eventsKey = new Map();
22
- }
23
- _createClass(EventCenter, [{
24
- key: "on",
25
- value: function on(name, func) {
26
- var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
27
- if (key) {
28
- if (this.eventsKey.has("".concat(name, "-").concat(key))) {
29
- // eslint-disable-next-line no-console
30
- console.warn("".concat(key, "\uFF1AHas been registered. Please use another key or do not pass the key"));
31
- return;
32
- }
33
- this.eventsKey.set("".concat(name, "-").concat(key), true);
34
- }
35
- var eventList = this.events.get(name) || [];
36
- eventList.push({
37
- func: func,
38
- key: key || ''
39
- });
40
- this.events.set(name, eventList);
41
- }
42
- }, {
43
- key: "off",
44
- value: function off(name, func) {
45
- var key = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
46
- if (key && this.eventsKey.has("".concat(name, "-").concat(key))) {
47
- this.eventsKey.delete("".concat(name, "-").concat(key));
48
- }
49
- if (this.events.has(name)) {
50
- var eventList = this.events.get(name);
51
- eventList = eventList.filter(function (item) {
52
- if (func === item.func && item.key === key) return false;
53
- if (item.key && item.key === key) return false;
54
- return true;
55
- });
56
- this.events.set(name, eventList);
57
- }
58
- }
59
- }, {
60
- key: "emit",
61
- value: function emit(name) {
62
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
63
- rest[_key - 1] = arguments[_key];
64
- }
65
- if (this.events.has(name)) {
66
- var eventList = this.events.get(name);
67
- eventList.forEach(function (item) {
68
- item.func.apply(item, rest);
69
- });
70
- }
71
- }
72
- }, {
73
- key: "once",
74
- value: function once(name, func, key) {
75
- var _this = this;
76
- var onceF = function onceF() {
77
- func.apply(void 0, arguments);
78
- _this.off(name, onceF, key);
79
- };
80
- this.on(name, onceF, key);
81
- }
82
- }, {
83
- key: "isExist",
84
- value: function isExist(name) {
85
- return this.events.has(name);
86
- }
87
- }]);
88
- return EventCenter;
89
- }();
9
+
90
10
  var getType = function getType(target) {
91
11
  return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
92
12
  };
@@ -266,7 +186,7 @@ function parseBase64ToString(base64) {
266
186
  }
267
187
  }
268
188
  function loadSDKScript(_ref, logger) {
269
- var _this2 = this;
189
+ var _this = this;
270
190
  var src = _ref.src,
271
191
  _ref$attrOptions = _ref.attrOptions,
272
192
  attrOptions = _ref$attrOptions === void 0 ? {} : _ref$attrOptions,
@@ -315,7 +235,7 @@ function loadSDKScript(_ref, logger) {
315
235
  reject(false);
316
236
  };
317
237
  timer = setTimeout(function () {
318
- _this2.logger.logError({
238
+ _this.logger.logError({
319
239
  title: 'load_item_sdk_timeout'
320
240
  }, {
321
241
  src: src,
@@ -331,4 +251,4 @@ function loadSDKScript(_ref, logger) {
331
251
  document.head.appendChild(script);
332
252
  });
333
253
  }
334
- export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
254
+ export { getType, getViewPort, getOrigin, serialize, isJsonString, isDom, isFunction, device, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent, getOrSetStorageId, checkTimeElapsed, parseBase64ToString, loadSDKScript };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1730107332-dev.3",
3
+ "version": "0.0.1730107332-dev.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",