@alipay/ams-checkout 0.0.1726734012-dev.1 → 0.0.1726734012-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.d.ts +19 -0
  3. package/esm/component/channel.js +87 -0
  4. package/esm/component/component.inline.style.d.ts +10 -0
  5. package/esm/component/component.inline.style.js +121 -0
  6. package/esm/component/component.popup.style.d.ts +25 -0
  7. package/esm/component/component.popup.style.js +203 -0
  8. package/esm/component/popupWindow.style.d.ts +11 -0
  9. package/esm/component/popupWindow.style.js +121 -0
  10. package/esm/config/index.d.ts +11 -0
  11. package/esm/config/index.js +20 -1
  12. package/esm/constant/index.d.ts +25 -0
  13. package/esm/constant/index.js +28 -0
  14. package/esm/core/bus/index.d.ts +3 -3
  15. package/esm/core/bus/index.js +14 -14
  16. package/esm/core/component/address.d.ts +8 -0
  17. package/esm/core/component/address.js +72 -0
  18. package/esm/core/component/appPreloadProcessing.js +2 -2
  19. package/esm/core/component/ckp/index.js +12 -8
  20. package/esm/core/component/element/components/address.d.ts +19 -0
  21. package/esm/core/component/element/components/address.js +68 -0
  22. package/esm/core/component/element/components/auth.d.ts +17 -0
  23. package/esm/core/component/element/components/auth.js +60 -0
  24. package/esm/core/component/element/components/payment.d.ts +19 -0
  25. package/esm/core/component/element/components/payment.js +74 -0
  26. package/esm/core/component/element/index.d.ts +47 -0
  27. package/esm/core/component/element/index.js +817 -0
  28. package/esm/core/component/element/mock.d.ts +4 -0
  29. package/esm/core/component/element/mock.js +491 -0
  30. package/esm/core/component/element/type.d.ts +191 -0
  31. package/esm/core/component/element/type.js +36 -0
  32. package/esm/core/component/element/utils.d.ts +13 -0
  33. package/esm/core/component/element/utils.js +6 -0
  34. package/esm/core/component/index.d.ts +12 -7
  35. package/esm/core/component/index.js +133 -78
  36. package/esm/core/drop-in/index.js +2 -2
  37. package/esm/core/instance/index.d.ts +1 -0
  38. package/esm/core/instance/index.js +24 -11
  39. package/esm/foundation/core/index.d.ts +28 -0
  40. package/esm/foundation/core/index.js +396 -0
  41. package/esm/foundation/index.d.ts +75 -0
  42. package/esm/foundation/index.js +42 -0
  43. package/esm/foundation/product-processor/easysafepay/deps.d.ts +18 -0
  44. package/esm/foundation/product-processor/easysafepay/deps.js +12 -0
  45. package/esm/foundation/product-processor/easysafepay/index.d.ts +26 -0
  46. package/esm/foundation/product-processor/easysafepay/index.js +464 -0
  47. package/esm/foundation/service/api-bus/ability/callback.d.ts +9 -0
  48. package/esm/foundation/service/api-bus/ability/callback.js +55 -0
  49. package/esm/foundation/service/api-bus/ability/globalData.d.ts +10 -0
  50. package/esm/foundation/service/api-bus/ability/globalData.js +89 -0
  51. package/esm/foundation/service/api-bus/ability/request.d.ts +10 -0
  52. package/esm/foundation/service/api-bus/ability/request.js +151 -0
  53. package/esm/foundation/service/api-bus/ability/security.d.ts +12 -0
  54. package/esm/foundation/service/api-bus/ability/security.js +161 -0
  55. package/esm/foundation/service/api-bus/ability/tracker.d.ts +9 -0
  56. package/esm/foundation/service/api-bus/ability/tracker.js +80 -0
  57. package/esm/foundation/service/api-bus/busManager.d.ts +127 -0
  58. package/esm/foundation/service/api-bus/busManager.js +398 -0
  59. package/esm/foundation/service/api-bus/index.d.ts +20 -0
  60. package/esm/foundation/service/api-bus/index.js +88 -0
  61. package/esm/foundation/service/api-bus/interface.d.ts +48 -0
  62. package/esm/foundation/service/api-bus/interface.js +54 -0
  63. package/esm/foundation/service/container/index.d.ts +32 -0
  64. package/esm/foundation/service/container/index.js +330 -0
  65. package/esm/foundation/service/container/popup.d.ts +17 -0
  66. package/esm/foundation/service/container/popup.js +103 -0
  67. package/esm/foundation/service/container/utils.d.ts +7 -0
  68. package/esm/foundation/service/container/utils.js +48 -0
  69. package/esm/foundation/service/event-center.d.ts +82 -0
  70. package/esm/foundation/service/event-center.js +274 -0
  71. package/esm/foundation/service/global-data/index.d.ts +11 -0
  72. package/esm/foundation/service/global-data/index.js +68 -0
  73. package/esm/foundation/service/index.d.ts +19 -0
  74. package/esm/foundation/service/index.js +82 -0
  75. package/esm/foundation/service/log/index.d.ts +43 -0
  76. package/esm/foundation/service/log/index.js +250 -0
  77. package/esm/foundation/service/log/keys.d.ts +13 -0
  78. package/esm/foundation/service/log/keys.js +103 -0
  79. package/esm/foundation/service/log/processor.d.ts +9 -0
  80. package/esm/foundation/service/log/processor.js +148 -0
  81. package/esm/foundation/service/log/types.d.ts +32 -0
  82. package/esm/foundation/service/log/types.js +1 -0
  83. package/esm/foundation/service/requester/deps.d.ts +17 -0
  84. package/esm/foundation/service/requester/deps.js +11 -0
  85. package/esm/foundation/service/requester/requester.d.ts +22 -0
  86. package/esm/foundation/service/requester/requester.js +217 -0
  87. package/esm/foundation/service/security/index.d.ts +28 -0
  88. package/esm/foundation/service/security/index.js +284 -0
  89. package/esm/foundation/service/security/security.d.ts +33 -0
  90. package/esm/foundation/service/security/security.js +182 -0
  91. package/esm/foundation/utils/gray_scale_utils.d.ts +7 -0
  92. package/esm/foundation/utils/gray_scale_utils.js +40 -0
  93. package/esm/foundation/utils/payment_context_utils.d.ts +13 -0
  94. package/esm/foundation/utils/payment_context_utils.js +57 -0
  95. package/esm/foundation/utils/payment_product_utils.d.ts +13 -0
  96. package/esm/foundation/utils/payment_product_utils.js +38 -0
  97. package/esm/foundation/utils/redirect_utils.d.ts +11 -0
  98. package/esm/foundation/utils/redirect_utils.js +262 -0
  99. package/esm/foundation/utils/system_events.d.ts +4 -0
  100. package/esm/foundation/utils/system_events.js +66 -0
  101. package/esm/foundation/utils/web_app_url_utils.d.ts +46 -0
  102. package/esm/foundation/utils/web_app_url_utils.js +112 -0
  103. package/esm/index.d.ts +19 -12
  104. package/esm/index.js +110 -56
  105. package/esm/plugin/applepay/component.js +13 -11
  106. package/esm/plugin/applepay/index.js +10 -6
  107. package/esm/plugin/applepay/service.d.ts +2 -2
  108. package/esm/plugin/applepay/service.js +26 -18
  109. package/esm/plugin/component/cashierApp.d.ts +10 -8
  110. package/esm/plugin/component/cashierApp.js +48 -11
  111. package/esm/plugin/component/channel.d.ts +4 -3
  112. package/esm/plugin/component/channel.js +39 -2
  113. package/esm/plugin/component/component.inline.style.d.ts +9 -10
  114. package/esm/plugin/component/component.inline.style.js +93 -10
  115. package/esm/plugin/component/component.popup.style.d.ts +15 -6
  116. package/esm/plugin/component/component.popup.style.js +30 -7
  117. package/esm/plugin/component/index.d.ts +14 -8
  118. package/esm/plugin/component/index.js +383 -187
  119. package/esm/plugin/component/popupWindow.style.d.ts +5 -2
  120. package/esm/plugin/component/popupWindow.style.js +70 -14
  121. package/esm/plugin/const.js +5 -5
  122. package/esm/plugin/drop-in/index.d.ts +5 -5
  123. package/esm/plugin/drop-in/index.js +7 -7
  124. package/esm/plugin/payment-element/utils.d.ts +2 -0
  125. package/esm/plugin/payment-element/utils.js +6 -0
  126. package/esm/plugin/paypal/index.js +2 -1
  127. package/esm/plugin/type.d.ts +4 -3
  128. package/esm/service/element.d.ts +4 -0
  129. package/esm/service/element.js +51 -0
  130. package/esm/service/index.d.ts +1 -0
  131. package/esm/service/index.js +6 -2
  132. package/esm/types/index.d.ts +337 -40
  133. package/esm/types/index.js +119 -55
  134. package/esm/util/createIframeNode.d.ts +2 -2
  135. package/esm/util/createIframeNode.js +3 -3
  136. package/esm/util/getBackScheme.d.ts +5 -0
  137. package/esm/util/getBackScheme.js +133 -0
  138. package/esm/util/index.js +4 -8
  139. package/esm/util/logger.d.ts +3 -3
  140. package/esm/util/logger.js +49 -13
  141. package/esm/util/security.d.ts +3 -2
  142. package/esm/util/security.js +2 -2
  143. package/esm/util/spm-map.d.ts +172 -0
  144. package/esm/util/spm-map.js +172 -0
  145. package/package.json +3 -1
@@ -0,0 +1,36 @@
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 _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; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ 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); }
5
+ export var ThemeType = /*#__PURE__*/function (ThemeType) {
6
+ ThemeType["NostalgicGray"] = "nostalgicGray";
7
+ ThemeType["Default"] = "default";
8
+ ThemeType["Night"] = "night";
9
+ ThemeType["CherryBlossomPink"] = "cherryBlossomPink";
10
+ ThemeType["GamingPurple"] = "gamingPurple";
11
+ ThemeType["AgateGreen"] = "agateGreen";
12
+ return ThemeType;
13
+ }({});
14
+ export var addressTheme = _defineProperty(_defineProperty({}, ThemeType.Default, 'LIGHT'), ThemeType.Night, 'NIGHT');
15
+ export var EventCallbackCode = /*#__PURE__*/function (EventCallbackCode) {
16
+ EventCallbackCode["Failed"] = "Failed";
17
+ EventCallbackCode["Completed"] = "Completed";
18
+ return EventCallbackCode;
19
+ }({});
20
+ export var ELEMENT_ENVIRONMENT = /*#__PURE__*/function (ELEMENT_ENVIRONMENT) {
21
+ ELEMENT_ENVIRONMENT["DEV"] = "DEV";
22
+ ELEMENT_ENVIRONMENT["TEST"] = "TEST";
23
+ ELEMENT_ENVIRONMENT["SIT"] = "SIT";
24
+ ELEMENT_ENVIRONMENT["PRE"] = "PRE";
25
+ ELEMENT_ENVIRONMENT["PROD"] = "PROD";
26
+ ELEMENT_ENVIRONMENT["SANDBOX"] = "SANDBOX";
27
+ return ELEMENT_ENVIRONMENT;
28
+ }({});
29
+ // export type IMountOptions = AddressMountOptions | LinkAuthMountOptions | PaymentMountOptions;
30
+
31
+ export var AddressEventCallbackName = /*#__PURE__*/function (AddressEventCallbackName) {
32
+ AddressEventCallbackName["SHIPPING_CHANGE"] = "SHIPPING_CHANGE";
33
+ return AddressEventCallbackName;
34
+ }({});
35
+
36
+ // export type IMountResult = AddressMountResult | LinkAuthMountResult | PaymentMountResult;
@@ -0,0 +1,13 @@
1
+ export interface ISessionDataExtendInfo {
2
+ displayLayout: 'LEFT_ORDER_AND_RIGHT_PAYMENT' | 'LEFT_PAYMENT_AND_RIGHT_ORDER';
3
+ displayAntomLogo: string;
4
+ themeType: 'LIGHT' | 'NIGHT' | 'CUSTOMIZE';
5
+ OPEN_MULTI_PAYMENT_ABILITY: boolean;
6
+ [key: string]: any;
7
+ }
8
+ export interface LinkData {
9
+ linkId: string;
10
+ region: string;
11
+ displaySetting?: ISessionDataExtendInfo;
12
+ }
13
+ export declare const displayIframe: (selector: string) => void;
@@ -0,0 +1,6 @@
1
+ export var displayIframe = function displayIframe(selector) {
2
+ var dom = document.querySelector(selector);
3
+ dom.style.opacity = '1';
4
+ dom.style.overflow = 'visible';
5
+ dom.style.height = '110px';
6
+ };
@@ -1,14 +1,18 @@
1
1
  import ComponentApp from '../../plugin/component';
2
- import { componentSignEnum, IcreateComponent, IoptionsParams, IpaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
2
+ import { ComponentSignEnum, IcreateComponent, IoptionsParams, IPaymentSessionMetaData, Iselector, Isubmit, PaymentMethodTypeEnum, SubPaymentMethodTypeEnum } from '../../types';
3
3
  import CoreInstance from '../instance/index';
4
- export declare const getComponentSign: (params: IpaymentSessionMetaData) => componentSignEnum;
5
- export declare const parseSessionData: (sessionData: string) => [IpaymentSessionMetaData, string];
4
+ export declare const getComponentSign: (params: IPaymentSessionMetaData) => ComponentSignEnum;
5
+ export declare const parseSessionData: (sessionData: string) => [IPaymentSessionMetaData, string];
6
+ export type IAMSComponentOptions = IoptionsParams & {
7
+ appVersion: string;
8
+ };
6
9
  export declare class AMSComponent extends CoreInstance {
7
10
  _componentApp: ComponentApp;
8
- channelType: componentSignEnum[];
11
+ channelType: ComponentSignEnum[];
9
12
  productSceneVersion: string;
10
13
  timer: any;
11
- constructor(options: IoptionsParams);
14
+ isSuccessfullyPreloaded: boolean;
15
+ constructor(options: IAMSComponentOptions);
12
16
  private parameterInitAndCheck;
13
17
  private pluginAppendIframe;
14
18
  private savePreviousChannel;
@@ -30,8 +34,8 @@ export declare class AMSComponent extends CoreInstance {
30
34
  */
31
35
  createComponent(params: IcreateComponent): Promise<void>;
32
36
  private createComponentProcess;
33
- preloadComponent(channelType: any, productSceneVersion: any): void;
34
- clearPreloadIframe(isTimeOut?: boolean): void;
37
+ preloadComponent(): void;
38
+ private clearPreloadIframe;
35
39
  /**
36
40
  * @description Create and render components in the specified element area
37
41
  * @param params - The data source created by the component, necessary sessionData, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
@@ -45,4 +49,5 @@ export declare class AMSComponent extends CoreInstance {
45
49
  * @param data - Transfer information in the submission interface according to your requirements (optional)
46
50
  */
47
51
  submit(data?: Isubmit): Promise<unknown>;
52
+ preload(_options: any): void;
48
53
  }
@@ -17,6 +17,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
17
17
  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; }
18
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
19
  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); }
20
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
21
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
20
24
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
25
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
26
  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); }
@@ -36,7 +40,7 @@ import { ApplePayBusSubscriber } from "../../plugin/applepay";
36
40
  import ComponentApp from "../../plugin/component";
37
41
  import { ExtendPlugin } from "../../plugin/const";
38
42
  import { PaypalBusSubscriber } from "../../plugin/paypal";
39
- import { componentSignEnum, environmentEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
43
+ import { ComponentSignEnum, ComponentSignEnumV2, EnvironmentEnum, modeEnum, networkModeEnum, ProductSceneEnum, DisplayTypeEnum } from "../../types";
40
44
  import { getOrSetStorageId, isPC, parseBase64ToString } from "../../util";
41
45
  import { createIframeNode, createPreloadIframeNode } from "../../util/createIframeNode";
42
46
  import { getSecurityConfigStorageKey } from "../../util/security";
@@ -53,7 +57,9 @@ export var getComponentSign = function getComponentSign(params) {
53
57
  productScene = _params$paymentSessio3 === void 0 ? '' : _params$paymentSessio3,
54
58
  _params$paymentSessio4 = _params$paymentSessio2.paymentMethodCategoryType,
55
59
  paymentMethodCategoryType = _params$paymentSessio4 === void 0 ? '' : _params$paymentSessio4;
56
- return productScene && paymentMethodCategoryType ? "".concat(productScene, "_").concat(paymentMethodCategoryType) : componentSignEnum.NONE;
60
+ if (productScene && paymentMethodCategoryType) return "".concat(productScene, "_").concat(paymentMethodCategoryType);
61
+ if (productScene) return "".concat(productScene);
62
+ return ComponentSignEnum.NONE;
57
63
  };
58
64
  export var parseSessionData = function parseSessionData(sessionData) {
59
65
  try {
@@ -68,7 +74,7 @@ export var parseSessionData = function parseSessionData(sessionData) {
68
74
  var resetEasyPaySceneVersion = function resetEasyPaySceneVersion(parseData) {
69
75
  if (isPC() && parseData !== null && parseData !== void 0 && parseData.paymentSessionConfig) {
70
76
  var productScene = parseData.paymentSessionConfig.productScene;
71
- if (productScene === productSceneEnum.EASY_PAY) {
77
+ if (productScene === ProductSceneEnum.EASY_PAY) {
72
78
  var _parseData$paymentMet;
73
79
  // 非TOSS渠道,在PC场景需要改成1.0
74
80
  if ('BANKTRANSFER_QUICKPAY' !== (parseData === null || parseData === void 0 || (_parseData$paymentMet = parseData.paymentMethodInfoView) === null || _parseData$paymentMet === void 0 ? void 0 : _parseData$paymentMet.paymentMethodType)) {
@@ -85,17 +91,26 @@ var handleSessionData = function handleSessionData(originSessionData) {
85
91
  resetEasyPaySceneVersion(parseData);
86
92
  return [parseData !== null && parseData !== void 0 ? parseData : {}, sessionData];
87
93
  };
88
- var handleParams = function handleParams(params) {
94
+ var handleParams = function handleParams(params, _this) {
89
95
  var _params = Object.assign({
90
96
  paymentSessionMetaData: {},
91
- renderDisplayType: renderDisplayTypeEnum.popup
97
+ renderDisplayType: DisplayTypeEnum.popup
92
98
  }, params);
93
99
  var _handleSessionData = handleSessionData(_params.sessionData || (_params === null || _params === void 0 ? void 0 : _params.paymentSessionData)),
94
100
  _handleSessionData2 = _slicedToArray(_handleSessionData, 2),
95
101
  parseData = _handleSessionData2[0],
96
102
  sessionData = _handleSessionData2[1];
97
103
  var componentSign = getComponentSign(parseData);
98
- if (componentSign === componentSignEnum.NONE) {
104
+ if (_toConsumableArray(Object.values(ComponentSignEnumV2)).includes(componentSign) && _params.renderDisplayType === DisplayTypeEnum.popup) {
105
+ return Promise.reject({
106
+ code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
107
+ message: "unsupported payment method"
108
+ });
109
+ }
110
+ if (_this.options.product === ProductSceneEnum.ELEMENT_ADDRESS) {
111
+ componentSign = ComponentSignEnum.ELEMENT_ADDRESS;
112
+ }
113
+ if (componentSign === ComponentSignEnum.NONE) {
99
114
  // eslint-disable-next-line prefer-promise-reject-errors
100
115
  return Promise.reject({
101
116
  code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
@@ -118,21 +133,24 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
118
133
  _inherits(AMSComponent, _CoreInstance);
119
134
  var _super = _createSuper(AMSComponent);
120
135
  function AMSComponent(options) {
121
- var _this;
136
+ var _this2;
122
137
  _classCallCheck(this, AMSComponent);
123
- _this = _super.call(this, options);
138
+ _this2 = _super.call(this, options);
124
139
  // Instantiate the plug-in and set render
125
- _defineProperty(_assertThisInitialized(_this), "channelType", void 0);
126
- _defineProperty(_assertThisInitialized(_this), "productSceneVersion", void 0);
127
- _defineProperty(_assertThisInitialized(_this), "timer", void 0);
128
- var ComponentPlugin = new ComponentApp();
140
+ _defineProperty(_assertThisInitialized(_this2), "channelType", void 0);
141
+ _defineProperty(_assertThisInitialized(_this2), "productSceneVersion", void 0);
142
+ _defineProperty(_assertThisInitialized(_this2), "timer", void 0);
143
+ _defineProperty(_assertThisInitialized(_this2), "isSuccessfullyPreloaded", void 0);
144
+ var ComponentPlugin = new ComponentApp({
145
+ appVersion: options.appVersion
146
+ });
129
147
  ComponentPlugin.setRender(createIframeNode);
130
148
  ComponentPlugin.setPreloadRender(createPreloadIframeNode);
131
149
  // Register Cashier Application Plug in
132
- _this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
133
- _this._componentApp = _this._getPlugin(COMPONENTPLUGINID);
134
- _this.registerBusAbility();
135
- return _this;
150
+ _this2._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
151
+ _this2._componentApp = _this2._getPlugin(COMPONENTPLUGINID);
152
+ _this2.registerBusAbility();
153
+ return _this2;
136
154
  }
137
155
  _createClass(AMSComponent, [{
138
156
  key: "parameterInitAndCheck",
@@ -146,7 +164,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
146
164
  selector: selector,
147
165
  renderDisplayType: renderDisplayType
148
166
  }, params);
149
- if (_params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
167
+ if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS && _params && !_params.sessionData && !(_params !== null && _params !== void 0 && _params.paymentSessionData)) {
150
168
  return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
151
169
  }
152
170
  if (this.options.networkMode === networkModeEnum.proxy) {
@@ -202,29 +220,24 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
202
220
  this.logger.logInfo({
203
221
  title: 'preload_match'
204
222
  }, {
205
- preloadChannel: this.channelType,
206
- preloadVersion: this.productSceneVersion,
207
- sessionDataChannel: channelType,
208
- sessionDataVersion: productSceneVersion
223
+ eventMessage: channelType,
224
+ productSceneVersion: productSceneVersion
209
225
  });
210
226
  } else {
211
227
  this.logger.logInfo({
212
228
  title: 'preload_no_match'
213
229
  }, {
214
- preloadChannel: this.channelType,
215
- preloadVersion: this.productSceneVersion,
216
- sessionDataChannel: channelType,
217
- sessionDataVersion: productSceneVersion
230
+ eventMessage: channelType,
231
+ productSceneVersion: productSceneVersion
218
232
  });
219
233
  }
220
234
  var previousChannel = {
221
- channelType: channelType === componentSignEnum.VAULTING_CARD ? componentSignEnum.CASHIER_PAYMENT_CARD : channelType,
235
+ channelType: channelType === ComponentSignEnum.VAULTING_CARD ? ComponentSignEnum.CASHIER_PAYMENT_CARD : channelType,
222
236
  productSceneVersion: productSceneVersion
223
237
  };
224
238
  localStorage.setItem('antom_checkout_previousChannel', JSON.stringify(previousChannel));
225
239
  }
226
240
  }
227
-
228
241
  /**
229
242
  * 初始化 Bus总线的能力
230
243
  */
@@ -232,12 +245,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
232
245
  key: "registerBusAbility",
233
246
  value: function registerBusAbility() {
234
247
  var _this$originOptions,
235
- _this2 = this;
236
- BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== environmentEnum.prod, this.logger);
248
+ _this3 = this;
249
+ BusManager.debugTrace(((_this$originOptions = this.originOptions) === null || _this$originOptions === void 0 ? void 0 : _this$originOptions.environment) !== EnvironmentEnum.prod, this.logger);
237
250
  BusManager.clear();
238
251
  BusManager.addInterceptor({
239
252
  onPublishException: function onPublishException(message, e) {
240
- _this2.logger.logError({
253
+ _this3.logger.logError({
241
254
  title: 'onBusPublishException'
242
255
  }, _objectSpread(_objectSpread({}, message), {}, {
243
256
  errorMessage: JSON.stringify(e)
@@ -246,12 +259,12 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
246
259
  });
247
260
  // subscribe basic ablility
248
261
  BusManager.subscribe(new SDKCallbackBusSubscriber(function (state) {
249
- var _this2$_componentApp;
250
- (_this2$_componentApp = _this2._componentApp) === null || _this2$_componentApp === void 0 || (_this2$_componentApp = _this2$_componentApp.AMSSDK) === null || _this2$_componentApp === void 0 || _this2$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
262
+ var _this3$_componentApp;
263
+ (_this3$_componentApp = _this3._componentApp) === null || _this3$_componentApp === void 0 || (_this3$_componentApp = _this3$_componentApp.AMSSDK) === null || _this3$_componentApp === void 0 || _this3$_componentApp._eventCenter.emit(EVENT.eventCallback.name, state);
251
264
  }));
252
265
  BusManager.subscribe(new SecurityBusSubscriber(function (deviceIdParameter, isPolling) {
253
- var _this2$_componentApp2;
254
- return (_this2$_componentApp2 = _this2._componentApp) === null || _this2$_componentApp2 === void 0 ? void 0 : _this2$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
266
+ var _this3$_componentApp2;
267
+ return (_this3$_componentApp2 = _this3._componentApp) === null || _this3$_componentApp2 === void 0 ? void 0 : _this3$_componentApp2.getDeviceIdAndLog(deviceIdParameter, isPolling);
255
268
  }));
256
269
  BusManager.subscribe(new TrackerBusSubscriber(this.logger));
257
270
  // subscribe plugin
@@ -266,7 +279,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
266
279
  }
267
280
  var paymentChannelMatcher = item.paymentChannelMatcher;
268
281
  if (paymentChannelMatcher) {
269
- _this2._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
282
+ _this3._registerPlugin(paymentChannelMatcher.paymentMethod, item.busActionNames);
270
283
  }
271
284
  var sessionMatcher = item.sessionMatcher;
272
285
  if (sessionMatcher) {
@@ -274,19 +287,18 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
274
287
  if (sessionMatcher.paymentMethodTypes) {
275
288
  sessionMatcher.paymentMethodTypes.forEach(function (paymentMethodType) {
276
289
  var subPluginKey = pluginKey + paymentMethodType;
277
- _this2._registerPlugin(subPluginKey, item.busActionNames);
290
+ _this3._registerPlugin(subPluginKey, item.busActionNames);
278
291
  });
279
292
  } else {
280
- _this2._registerPlugin(pluginKey, item.busActionNames);
293
+ _this3._registerPlugin(pluginKey, item.busActionNames);
281
294
  }
282
295
  }
283
296
  var optInit = item === null || item === void 0 || (_item$busActionNames = item.busActionNames) === null || _item$busActionNames === void 0 ? void 0 : _item$busActionNames.optional_init;
284
297
  if (optInit) {
285
- BusManager.publish(new BusMessage(optInit, JSON.stringify(_this2.originOptions)));
298
+ BusManager.publish(new BusMessage(optInit, JSON.stringify(_this3.originOptions)));
286
299
  }
287
300
  });
288
301
  }
289
-
290
302
  /**
291
303
  * To determine whether the corresponding payment method is available,
292
304
  * only the channel described in the document will be called, and it will be returned as available by default
@@ -297,14 +309,14 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
297
309
  }, {
298
310
  key: "canMakePayments",
299
311
  value: function canMakePayments(paymentMethod, subPaymentMethod) {
300
- var _this3 = this;
312
+ var _this4 = this;
301
313
  // 判断支付方式是否可用
302
314
  return new Promise(function (resolve) {
303
- var _this3$_getPlugin;
315
+ var _this4$_getPlugin;
304
316
  if (!paymentMethod) {
305
317
  return resolve(true);
306
318
  }
307
- var actionName = (_this3$_getPlugin = _this3._getPlugin(paymentMethod)) === null || _this3$_getPlugin === void 0 ? void 0 : _this3$_getPlugin.canMakePayments;
319
+ var actionName = (_this4$_getPlugin = _this4._getPlugin(paymentMethod)) === null || _this4$_getPlugin === void 0 ? void 0 : _this4$_getPlugin.canMakePayments;
308
320
  if (actionName && BusManager.isSubscribed(actionName)) {
309
321
  BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
310
322
  paymentMethod: paymentMethod,
@@ -314,10 +326,10 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
314
326
  }).then(function (message) {
315
327
  resolve(message.getJSONObject());
316
328
  }).catch(function (e) {
317
- _this3.logger.logInfo({
329
+ _this4.logger.logInfo({
318
330
  title: 'canMakePayments_error'
319
331
  }, {
320
- params: JSON.stringify(e)
332
+ errorMessage: JSON.stringify(e)
321
333
  });
322
334
  resolve(false);
323
335
  });
@@ -326,7 +338,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
326
338
  }
327
339
  });
328
340
  }
329
-
330
341
  /**
331
342
  * @description Create component application
332
343
  * @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.
@@ -334,26 +345,31 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
334
345
  }, {
335
346
  key: "createComponent",
336
347
  value: function createComponent(params) {
337
- var _this4 = this;
348
+ var _this5 = this;
349
+ if (!this.isSuccessfullyPreloaded) {
350
+ this.preloadComponent();
351
+ }
352
+ ;
353
+ console.log('执行了createComponent', params);
338
354
  this.clearPreloadIframe();
339
355
  this.logger.setComponentStartTime(Date.now());
340
356
  return this.parameterInitAndCheck({
341
357
  params: params,
342
- renderDisplayType: renderDisplayTypeEnum.popup
358
+ renderDisplayType: DisplayTypeEnum.popup
343
359
  }).then(function (_params) {
344
- return handleParams(_params);
360
+ return handleParams(_params, _this5);
345
361
  }).catch(function (error) {
346
- _this4.logger.logError({
362
+ _this5.logger.logError({
347
363
  title: 'sdk_error_parameter'
348
364
  }, {
349
365
  params: JSON.stringify(params)
350
366
  }).send();
351
- _this4._eventCenter.emit(EVENT.error.name, error);
367
+ _this5._eventCenter.emit(EVENT.error.name, error);
352
368
  return Promise.reject(error);
353
369
  }).then(function (appendParams) {
354
370
  var iframeNodesParams = appendParams.iframeNodesParams;
355
- _this4.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
356
- return _this4.createComponentProcess(appendParams);
371
+ _this5.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
372
+ return _this5.createComponentProcess(appendParams);
357
373
  });
358
374
  }
359
375
  }, {
@@ -374,26 +390,46 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
374
390
  this.savePreviousChannel(iframeNodesParams);
375
391
  return this.pluginAppendIframe(appendParams);
376
392
  }
393
+
394
+ // preloadComponent(channelType, productSceneVersion) {
395
+ // this.channelType = channelType;
396
+ // this.productSceneVersion = productSceneVersion;
397
+ // const MAX_CLEAR_TIME = 10000;
398
+
399
+ // if (Array.isArray(channelType)) {
400
+ // for (let i = 0; i < channelType.length; i++) {
401
+ // this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
402
+ // }
403
+ // } else {
404
+ // this.logger.logError(
405
+ // { title: 'performance_optimization_channelType_error' },
406
+ // { eventMessage: channelType }
407
+ // );
408
+ // }
409
+ // this.timer = setTimeout(() => {
410
+ // this.clearPreloadIframe(true);
411
+ // }, MAX_CLEAR_TIME);
412
+ // }
377
413
  }, {
378
414
  key: "preloadComponent",
379
- value: function preloadComponent(channelType, productSceneVersion) {
380
- var _this5 = this;
381
- this.channelType = channelType;
382
- this.productSceneVersion = productSceneVersion;
415
+ value: function preloadComponent() {
416
+ var _this6 = this;
417
+ console.log('执行了preloadComponent');
383
418
  var MAX_CLEAR_TIME = 10000;
384
- if (Array.isArray(channelType)) {
385
- for (var i = 0; i < channelType.length; i++) {
386
- this._componentApp.appendPreloadIframeNodes(channelType[i], productSceneVersion);
419
+ if (Array.isArray(this.channelType)) {
420
+ for (var i = 0; i < this.channelType.length; i++) {
421
+ this._componentApp.appendPreloadIframeNodes(this.channelType[i], this.productSceneVersion);
387
422
  }
423
+ this.isSuccessfullyPreloaded = true;
388
424
  } else {
389
425
  this.logger.logError({
390
426
  title: 'performance_optimization_channelType_error'
391
427
  }, {
392
- channelType: channelType
428
+ eventMessage: this.channelType
393
429
  });
394
430
  }
395
431
  this.timer = setTimeout(function () {
396
- _this5.clearPreloadIframe(true);
432
+ _this6.clearPreloadIframe(true);
397
433
  }, MAX_CLEAR_TIME);
398
434
  }
399
435
  }, {
@@ -425,27 +461,31 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
425
461
  }, {
426
462
  key: "mountComponent",
427
463
  value: function mountComponent(params, selector) {
428
- var _this6 = this;
464
+ var _this7 = this;
429
465
  this.clearPreloadIframe();
466
+ if (!this.isSuccessfullyPreloaded) {
467
+ this.preloadComponent();
468
+ }
469
+ ;
430
470
  this.logger.setComponentStartTime(Date.now());
431
471
  return this.parameterInitAndCheck({
432
472
  params: params,
433
- renderDisplayType: renderDisplayTypeEnum.inline,
473
+ renderDisplayType: DisplayTypeEnum.inline,
434
474
  selector: selector
435
475
  }).then(function (_params) {
436
- return handleParams(_params);
476
+ return handleParams(_params, _this7);
437
477
  }).catch(function (error) {
438
- _this6.logger.logError({
478
+ _this7.logger.logError({
439
479
  title: 'sdk_error_parameter'
440
480
  }, {
441
481
  params: JSON.stringify(params)
442
482
  }).send();
443
- _this6._eventCenter.emit(EVENT.error.name, error);
483
+ _this7._eventCenter.emit(EVENT.error.name, error);
444
484
  return Promise.reject(error);
445
485
  }).then(function (appendParams) {
446
486
  var iframeNodesParams = appendParams.iframeNodesParams;
447
- _this6.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
448
- return _this6.mountComponentProcess(appendParams);
487
+ _this7.logger.setTrackId(iframeNodesParams === null || iframeNodesParams === void 0 ? void 0 : iframeNodesParams.sessionData);
488
+ return _this7.mountComponentProcess(appendParams);
449
489
  });
450
490
  }
451
491
  }, {
@@ -463,10 +503,11 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
463
503
  return Promise.resolve();
464
504
  }
465
505
  var iframeNodesParams = appendParams.iframeNodesParams;
466
- this.savePreviousChannel(iframeNodesParams);
506
+ if (this.options.product !== ProductSceneEnum.ELEMENT_ADDRESS) {
507
+ this.savePreviousChannel(iframeNodesParams);
508
+ }
467
509
  return this.pluginAppendIframe(appendParams);
468
510
  }
469
-
470
511
  /**
471
512
  * @description Execute payment submission process
472
513
  * @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
@@ -475,30 +516,30 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
475
516
  }, {
476
517
  key: "submit",
477
518
  value: function submit(data) {
478
- var _this7 = this;
519
+ var _this8 = this;
479
520
  return new Promise(function (resolve, reject) {
480
521
  try {
481
- var _this7$getBusActionNa;
522
+ var _this8$getBusActionNa;
482
523
  var eventCallbackId = uuid();
483
- _this7.logger.logInfo({
524
+ _this8.logger.logInfo({
484
525
  title: 'sdk_event_apiSubmit'
485
526
  });
486
- var actionName = (_this7$getBusActionNa = _this7.getBusActionNames()) === null || _this7$getBusActionNa === void 0 ? void 0 : _this7$getBusActionNa.submit;
527
+ var actionName = (_this8$getBusActionNa = _this8.getBusActionNames()) === null || _this8$getBusActionNa === void 0 ? void 0 : _this8$getBusActionNa.submit;
487
528
  if (actionName && BusManager.isSubscribed(actionName)) {
488
529
  // 执行出错了,在通用拦截器返回
489
530
  BusManager.publishForResult(new BusMessage(actionName, JSON.stringify({
490
- appendParams: _this7._appendParams,
491
- options: _this7.originOptions,
531
+ appendParams: _this8._appendParams,
532
+ options: _this8.originOptions,
492
533
  data: data
493
534
  }))).then(function (busMessage) {
494
535
  resolve(busMessage === null || busMessage === void 0 ? void 0 : busMessage.getJSONObject());
495
536
  });
496
537
  } else {
497
538
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
498
- _this7._eventCenter.once(eventCallbackId, function (_data) {
539
+ _this8._eventCenter.once(eventCallbackId, function (_data) {
499
540
  resolve(_data);
500
541
  });
501
- _this7._componentApp.dispatchToApp({
542
+ _this8._componentApp.dispatchToApp({
502
543
  context: {
503
544
  event: 'submitPay',
504
545
  eventCallbackId: eventCallbackId,
@@ -511,6 +552,20 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
511
552
  }
512
553
  });
513
554
  }
555
+
556
+ // 预加载
557
+ }, {
558
+ key: "preload",
559
+ value: function preload(_options) {
560
+ var _this$channelType;
561
+ this.preloadComponent();
562
+ if ((_this$channelType = this.channelType) !== null && _this$channelType !== void 0 && _this$channelType.some(function (val) {
563
+ return val === ComponentSignEnum.EASY_PAY_WALLET || val === ComponentSignEnum.EASY_PAY_APM;
564
+ })) return;
565
+ this._componentApp.AMSSDK.initSecurity({
566
+ product: this.options.product
567
+ });
568
+ }
514
569
  }]);
515
570
  return AMSComponent;
516
571
  }(CoreInstance);
@@ -11,7 +11,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
11
  /* eslint-disable @typescript-eslint/no-explicit-any */
12
12
  import { BASEPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
13
13
  import CheckoutApp from "../../plugin/drop-in";
14
- import { messageName, networkModeEnum } from "../../types";
14
+ import { MessageName, networkModeEnum } from "../../types";
15
15
  import { createIframeNode } from "../../util/createIframeNode";
16
16
  export var mixinDropInConstructor = function mixinDropInConstructor(options, context) {
17
17
  // Instantiate the plug-in and set render
@@ -57,7 +57,7 @@ export var confirmPayment = function confirmPayment(result) {
57
57
  });
58
58
  });
59
59
  _this2.eventCenter.emit("".concat(BASEPLUGINID, "-handleRequestPayment"), {
60
- name: messageName.SDK_TO_APP,
60
+ name: MessageName.SDK_TO_APP,
61
61
  mode: _this2.options.mode,
62
62
  appId: BASEPLUGINID,
63
63
  instanceId: _this2._instanceId,
@@ -79,6 +79,7 @@ export default class AMSSDK {
79
79
  normalUrl?: string;
80
80
  schemeUrl?: string;
81
81
  applinkUrl?: string;
82
+ callAppJudgeTime?: number;
82
83
  }): Promise<void>;
83
84
  /**
84
85
  * @description Overlay Subscription