@alipay/ams-checkout 1.6.1 → 1.7.0

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.
@@ -140,13 +140,10 @@ export declare const EVENT: {
140
140
  dismissLoading: {
141
141
  name: string;
142
142
  };
143
- popupWindow: {
143
+ startDialog: {
144
144
  name: string;
145
145
  };
146
- closePopup: {
147
- name: string;
148
- };
149
- threedReady: {
146
+ popWindow: {
150
147
  name: string;
151
148
  };
152
149
  getDeviceId: {
@@ -155,6 +152,21 @@ export declare const EVENT: {
155
152
  declareEventCallbackInfo: {
156
153
  name: string;
157
154
  };
155
+ setGlobalData: {
156
+ name: string;
157
+ };
158
+ getGlobalData: {
159
+ name: string;
160
+ };
161
+ sendMuitiAppEventToSdk: {
162
+ name: string;
163
+ };
164
+ receiveMuitiAppFromSdk: {
165
+ name: string;
166
+ };
167
+ getUserAgentFromSdk: {
168
+ name: string;
169
+ };
158
170
  };
159
171
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
160
172
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -140,20 +140,32 @@ export var EVENT = {
140
140
  dismissLoading: {
141
141
  name: 'dismissLoading'
142
142
  },
143
- popupWindow: {
144
- name: 'popupWindow'
143
+ startDialog: {
144
+ name: 'startDialog'
145
145
  },
146
- closePopup: {
147
- name: 'closePopup'
148
- },
149
- threedReady: {
150
- name: 'threedReady'
146
+ popWindow: {
147
+ name: 'popWindow'
151
148
  },
152
149
  getDeviceId: {
153
150
  name: 'getDeviceId'
154
151
  },
155
152
  declareEventCallbackInfo: {
156
153
  name: 'declareEventCallbackInfo'
154
+ },
155
+ setGlobalData: {
156
+ name: 'setGlobalData'
157
+ },
158
+ getGlobalData: {
159
+ name: 'getGlobalData'
160
+ },
161
+ sendMuitiAppEventToSdk: {
162
+ name: 'sendMuitiAppEventToSdk'
163
+ },
164
+ receiveMuitiAppFromSdk: {
165
+ name: 'receiveMuitiAppFromSdk'
166
+ },
167
+ getUserAgentFromSdk: {
168
+ name: 'getUserAgentFromSdk'
157
169
  }
158
170
  };
159
171
  export var COMPONENT_CONTAINER_ID = 'ams-component-container';
@@ -138,9 +138,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
138
138
  key: "pluginAppendIframe",
139
139
  value: function pluginAppendIframe(appendParams) {
140
140
  try {
141
- this.logger.logInfo({
142
- title: 'sdk_event_createComponent'
143
- }).send();
144
141
  return this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
145
142
  } catch (error) {
146
143
  return Promise.reject(error);
@@ -163,16 +160,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
163
160
  _this2._eventCenter.emit(EVENT.error.name, error);
164
161
  return Promise.reject(error);
165
162
  }).then(function (appendParams) {
166
- var _appendParams$iframeN, _appendParams$iframeN2;
167
- // This version, easypay2.0 only supports alipayhk
168
- var productSceneVersion = appendParams === null || appendParams === void 0 || (_appendParams$iframeN = appendParams.iframeNodesParams) === null || _appendParams$iframeN === void 0 || (_appendParams$iframeN = _appendParams$iframeN.paymentSessionMetaData) === null || _appendParams$iframeN === void 0 || (_appendParams$iframeN = _appendParams$iframeN.paymentSessionConfig) === null || _appendParams$iframeN === void 0 ? void 0 : _appendParams$iframeN.productSceneVersion;
169
- var paymentMethodType = appendParams === null || appendParams === void 0 || (_appendParams$iframeN2 = appendParams.iframeNodesParams) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentSessionMetaData) === null || _appendParams$iframeN2 === void 0 || (_appendParams$iframeN2 = _appendParams$iframeN2.paymentMethodInfoView) === null || _appendParams$iframeN2 === void 0 ? void 0 : _appendParams$iframeN2.paymentMethodType;
170
- if ((appendParams === null || appendParams === void 0 ? void 0 : appendParams.componentSign) === componentSignEnum.EASY_PAY_WALLET && productSceneVersion === '2.0' && paymentMethodType !== 'ALIPAY_HK') {
171
- return Promise.reject({
172
- code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
173
- message: "Abnormal response data, interface failure, or unsupported payment method"
174
- });
175
- }
176
163
  return _this2.pluginAppendIframe(appendParams);
177
164
  });
178
165
  }
@@ -3,14 +3,14 @@ import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, Isele
3
3
  import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
4
4
  type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
5
5
  export default class ComponentApp {
6
- app: any;
6
+ app: null | HTMLIFrameElement;
7
7
  AMSSDK: AMSCheckout;
8
8
  platform: platformEnum;
9
9
  _performanceData: any[];
10
10
  _loadAppPromiseResolve: ((value: boolean) => void) | null;
11
11
  _isInitComponent: boolean;
12
- private _threedData?;
13
- private popupWindow?;
12
+ private _globalData?;
13
+ private popupApp?;
14
14
  private appDomain;
15
15
  private createIframeNode;
16
16
  private _selector;
@@ -44,9 +44,10 @@ export default class ComponentApp {
44
44
  * @description render iframe content
45
45
  */
46
46
  appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void>;
47
+ private setParameterDefaultValues;
47
48
  private renderInlineLoading;
48
49
  private renderPopupLoading;
49
- _createLoadAppPromise(): Promise<unknown>;
50
+ _createLoadAppPromise(loadTimeLimit?: number): Promise<unknown>;
50
51
  /**
51
52
  * @description Interface request
52
53
  */
@@ -59,8 +60,10 @@ export default class ComponentApp {
59
60
  private createApp;
60
61
  private listener;
61
62
  private resizeListener;
62
- private createPopupWindow;
63
+ private createDialog;
63
64
  private getDeviceIdAndCallback;
65
+ private getUserAgentAndCallback;
66
+ private returnDataAndCallback;
64
67
  /**
65
68
  * @description Initialize subscription iframe message
66
69
  */
@@ -15,7 +15,6 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
15
15
  * 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.
16
16
  */
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
- import { marmotMap } from "../../config/index";
19
18
  import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
20
19
  import { queryPaymentInfo, submitPayInfo } from "../../service";
21
20
  import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, RedirectType, renderDisplayTypeEnum, targetEnum } from "../../types";
@@ -35,8 +34,8 @@ var ComponentApp = /*#__PURE__*/function () {
35
34
  _defineProperty(this, "_performanceData", []);
36
35
  _defineProperty(this, "_loadAppPromiseResolve", null);
37
36
  _defineProperty(this, "_isInitComponent", void 0);
38
- _defineProperty(this, "_threedData", void 0);
39
- _defineProperty(this, "popupWindow", void 0);
37
+ _defineProperty(this, "_globalData", void 0);
38
+ _defineProperty(this, "popupApp", void 0);
40
39
  _defineProperty(this, "appDomain", void 0);
41
40
  _defineProperty(this, "createIframeNode", void 0);
42
41
  _defineProperty(this, "_selector", void 0);
@@ -49,7 +48,7 @@ var ComponentApp = /*#__PURE__*/function () {
49
48
  _defineProperty(this, "_appLocationSearch", void 0);
50
49
  _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
51
50
  _defineProperty(this, "_multipleCallbackEvents", void 0);
52
- this._appVersion = '1.6.1';
51
+ this._appVersion = '1.7.0';
53
52
  this._isInitComponent = false;
54
53
  this._selector = "#".concat(COMPONENT_SECTION_ID);
55
54
  this.createIframeNode = function () {
@@ -62,6 +61,7 @@ var ComponentApp = /*#__PURE__*/function () {
62
61
  key: 'sdk_init',
63
62
  value: Date.now()
64
63
  });
64
+ this._globalData = new Map();
65
65
  }
66
66
 
67
67
  /**
@@ -85,7 +85,7 @@ var ComponentApp = /*#__PURE__*/function () {
85
85
  }, {
86
86
  key: "initLoggerMeta",
87
87
  value: function initLoggerMeta() {
88
- var _this$_renderParams, _paymentSessionMetaDa;
88
+ var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2;
89
89
  var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
90
90
  var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
91
91
  this.AMSSDK.logger.setMedta({
@@ -100,7 +100,8 @@ var ComponentApp = /*#__PURE__*/function () {
100
100
  productScene: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productScene,
101
101
  productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
102
102
  paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
103
- paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType
103
+ paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
104
+ requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData
104
105
  });
105
106
  this.AMSSDK.logger.setComponentStartTime(Date.now());
106
107
  }
@@ -116,9 +117,9 @@ var ComponentApp = /*#__PURE__*/function () {
116
117
  }, {
117
118
  key: "initSecurity",
118
119
  value: function initSecurity() {
119
- var _this$_renderParams2,
120
+ var _this$_renderParams3,
120
121
  _this = this;
121
- var product = (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionMetaData) === null || _this$_renderParams2 === void 0 || (_this$_renderParams2 = _this$_renderParams2.paymentSessionConfig) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.productScene;
122
+ var product = (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionMetaData) === null || _this$_renderParams3 === void 0 || (_this$_renderParams3 = _this$_renderParams3.paymentSessionConfig) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.productScene;
122
123
  if (componentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
123
124
  this.AMSSDK.logger.logInfo({
124
125
  title: 'sdk_event_security_unneeded_scenarios'
@@ -227,19 +228,24 @@ var ComponentApp = /*#__PURE__*/function () {
227
228
  }, {
228
229
  key: "appendIframeNodes",
229
230
  value: function appendIframeNodes(componentSign, renderParams) {
230
- var _this3 = this;
231
+ var _renderParams,
232
+ _this3 = this;
231
233
  if (this._isInitComponent) {
232
234
  this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
233
235
  return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
234
236
  }
237
+ renderParams = this.setParameterDefaultValues(componentSign, renderParams);
235
238
  this._isInitComponent = true;
236
239
  this._renderParams = renderParams;
237
240
  this._componentSign = componentSign;
238
- if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
241
+ if ((_renderParams = renderParams) !== null && _renderParams !== void 0 && _renderParams.selector) this._selector = renderParams.selector;
239
242
  this._renderDisplayType = renderParams.renderDisplayType;
240
243
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
241
- this.initSecurity();
242
244
  this.initLoggerMeta();
245
+ this.AMSSDK.logger.logInfo({
246
+ title: 'sdk_event_createComponent'
247
+ }).send();
248
+ this.initSecurity();
243
249
  this._performanceData.push({
244
250
  key: 'sdk_create_component',
245
251
  value: Date.now()
@@ -270,6 +276,16 @@ var ComponentApp = /*#__PURE__*/function () {
270
276
  return Promise.reject(error);
271
277
  });
272
278
  }
279
+ }, {
280
+ key: "setParameterDefaultValues",
281
+ value: function setParameterDefaultValues(componentSign, renderParams) {
282
+ var newParams = Object.assign({}, renderParams);
283
+ if (componentSign === componentSignEnum.VAULTING_CARD) {
284
+ var _newParams$notRedirec;
285
+ newParams.notRedirectAfterComplete = (_newParams$notRedirec = newParams === null || newParams === void 0 ? void 0 : newParams.notRedirectAfterComplete) !== null && _newParams$notRedirec !== void 0 ? _newParams$notRedirec : true;
286
+ }
287
+ return newParams;
288
+ }
273
289
  }, {
274
290
  key: "renderInlineLoading",
275
291
  value: function renderInlineLoading(renderParams, selector) {
@@ -291,18 +307,15 @@ var ComponentApp = /*#__PURE__*/function () {
291
307
  }
292
308
  }, {
293
309
  key: "_createLoadAppPromise",
294
- value: function _createLoadAppPromise() {
310
+ value: function _createLoadAppPromise(loadTimeLimit) {
295
311
  var _this4 = this;
296
312
  return new Promise(function (resolve, reject) {
297
313
  _this4._loadAppPromiseResolve = resolve;
298
314
  setTimeout(function () {
299
315
  reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
300
- }, LOADTIME_LIMIT);
316
+ }, loadTimeLimit !== null && loadTimeLimit !== void 0 ? loadTimeLimit : LOADTIME_LIMIT);
301
317
  }).catch(function (error) {
302
- _this4.dispatchToSDK(EVENT.error.name, {
303
- code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
304
- message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
305
- });
318
+ _this4.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
306
319
  _this4.AMSSDK.logger.logError({
307
320
  title: 'sdk_error_web_app_timeout'
308
321
  }).send();
@@ -427,7 +440,7 @@ var ComponentApp = /*#__PURE__*/function () {
427
440
  resolve(res);
428
441
  }
429
442
  }).catch(function (err) {
430
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign) {
443
+ if ([componentSignEnum.CASHIER_PAYMENT_CARD, componentSignEnum.VAULTING_CARD].includes(_this5._componentSign)) {
431
444
  return resolve({
432
445
  success: false
433
446
  });
@@ -458,16 +471,16 @@ var ComponentApp = /*#__PURE__*/function () {
458
471
  }, {
459
472
  key: "createSubmitPromise",
460
473
  value: function createSubmitPromise() {
461
- var _this$_renderParams3,
462
- _this$_renderParams4,
474
+ var _this$_renderParams4,
475
+ _this$_renderParams5,
463
476
  _this6 = this;
464
477
  this._performanceData.push({
465
478
  key: 'sdk_submit_start',
466
479
  value: Date.now()
467
480
  });
468
481
  var params = {
469
- paymentSessionData: this._renderParams && ((_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData) || '',
470
- paymentSessionConfig: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.paymentSessionConfig
482
+ paymentSessionData: this._renderParams && ((_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.sessionData) || '',
483
+ paymentSessionConfig: (_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 || (_this$_renderParams5 = _this$_renderParams5.paymentSessionMetaData) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.paymentSessionConfig
471
484
  };
472
485
 
473
486
  // eslint-disable-next-line no-async-promise-executor
@@ -653,13 +666,12 @@ var ComponentApp = /*#__PURE__*/function () {
653
666
  });
654
667
  }
655
668
  }, {
656
- key: "createPopupWindow",
657
- value: function createPopupWindow(data) {
658
- var _this$_renderParams5;
659
- this._threedData = data;
660
- var sessionData = encodeURIComponent((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData);
661
- var threedPageUrl = "".concat(marmotMap[this.AMSSDK.options.env.environment], "/threedPage/index.html?scene=threedWrapperPage&sessionData=").concat(sessionData, "&").concat(this._appLocationSearch);
662
- this.popupWindow = createModal({
669
+ key: "createDialog",
670
+ value: function createDialog(data) {
671
+ var threedPageUrl = data.url.includes('?') ? "".concat(data.url, "&").concat(this._appLocationSearch) : "".concat(data.url, "?").concat(this._appLocationSearch);
672
+ this.popupApp = createModal({
673
+ widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
674
+ heightPadding: data === null || data === void 0 ? void 0 : data.heightPadding,
663
675
  device: this.platform,
664
676
  url: threedPageUrl
665
677
  });
@@ -700,6 +712,66 @@ var ComponentApp = /*#__PURE__*/function () {
700
712
  }
701
713
  return getDeviceIdAndCallback;
702
714
  }()
715
+ }, {
716
+ key: "getUserAgentAndCallback",
717
+ value: function () {
718
+ var _getUserAgentAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventContext) {
719
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
720
+ while (1) switch (_context5.prev = _context5.next) {
721
+ case 0:
722
+ if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
723
+ try {
724
+ this.dispatchToApp({
725
+ context: {
726
+ event: 'appEventCallback',
727
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
728
+ data: {
729
+ userAgent: window.navigator.userAgent
730
+ }
731
+ }
732
+ });
733
+ } catch (error) {/* empty */}
734
+ }
735
+ case 1:
736
+ case "end":
737
+ return _context5.stop();
738
+ }
739
+ }, _callee5, this);
740
+ }));
741
+ function getUserAgentAndCallback(_x5) {
742
+ return _getUserAgentAndCallback.apply(this, arguments);
743
+ }
744
+ return getUserAgentAndCallback;
745
+ }()
746
+ }, {
747
+ key: "returnDataAndCallback",
748
+ value: function () {
749
+ var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(eventContext) {
750
+ var _eventContext$data, targetData;
751
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
752
+ while (1) switch (_context6.prev = _context6.next) {
753
+ case 0:
754
+ if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
755
+ targetData = this._globalData.get((_eventContext$data = eventContext.data) === null || _eventContext$data === void 0 ? void 0 : _eventContext$data.dataKey);
756
+ this.dispatchToApp({
757
+ context: {
758
+ event: 'appEventCallback',
759
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
760
+ data: targetData
761
+ }
762
+ });
763
+ }
764
+ case 1:
765
+ case "end":
766
+ return _context6.stop();
767
+ }
768
+ }, _callee6, this);
769
+ }));
770
+ function returnDataAndCallback(_x6) {
771
+ return _returnDataAndCallback.apply(this, arguments);
772
+ }
773
+ return returnDataAndCallback;
774
+ }()
703
775
  /**
704
776
  * @description Initialize subscription iframe message
705
777
  */
@@ -725,7 +797,9 @@ var ComponentApp = /*#__PURE__*/function () {
725
797
  }, {
726
798
  key: "_handleAppMessage",
727
799
  value: function _handleAppMessage(data) {
728
- var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name, EVENT.popupWindow.name, EVENT.threedReady.name, EVENT.closePopup.name, EVENT.getDeviceId.name, EVENT.declareEventCallbackInfo.name];
800
+ var eventKeyMap = Object.keys(EVENT).map(function (key) {
801
+ return EVENT[key].name;
802
+ });
729
803
  if (!eventKeyMap.includes(data.context.event)) {
730
804
  return;
731
805
  }
@@ -733,29 +807,42 @@ var ComponentApp = /*#__PURE__*/function () {
733
807
  this.getDeviceIdAndCallback(data.context);
734
808
  return;
735
809
  }
736
- if (data.context.event === EVENT.closePopup.name) {
810
+ if (data.context.event === EVENT.getUserAgentFromSdk.name) {
811
+ this.getUserAgentAndCallback(data.context);
812
+ return;
813
+ }
814
+ if (data.context.event === EVENT.popWindow.name) {
737
815
  destroyModal();
738
816
  return;
739
817
  }
740
- if (data.context.event === EVENT.threedReady.name) {
741
- this.dispatchToApp({
742
- context: {
743
- event: 'renderThreedPage',
744
- data: this._threedData
745
- }
746
- }, this.popupWindow);
818
+ if (data.context.event === EVENT.getGlobalData.name) {
819
+ this.returnDataAndCallback(data.context);
747
820
  return;
748
821
  }
749
- if (data.context.event === EVENT.popupWindow.name) {
822
+ if (data.context.event === EVENT.setGlobalData.name) {
823
+ var _data$context$data, _data$context$data2;
824
+ this._globalData.set((_data$context$data = data.context.data) === null || _data$context$data === void 0 ? void 0 : _data$context$data.dataKey, (_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.data);
825
+ return;
826
+ }
827
+ if (data.context.event === EVENT.startDialog.name) {
750
828
  var _data$context;
751
- this.createPopupWindow((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
829
+ this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
830
+ return;
831
+ }
832
+ if (data.context.event === EVENT.sendMuitiAppEventToSdk.name) {
833
+ this.dispatchToApp({
834
+ context: {
835
+ event: 'receiveMuitiAppFromSdk',
836
+ data: data.context.data
837
+ }
838
+ });
752
839
  return;
753
840
  }
754
841
  if (data.context.event === EVENT.dismissLoading.name) {
755
- var _data$context$data;
842
+ var _data$context$data3;
756
843
  this.dispatchToSDK(EVENT.eventCallback.name, {
757
844
  code: 'SDK_END_OF_LOADING',
758
- message: ((_data$context$data = data.context.data) === null || _data$context$data === void 0 ? void 0 : _data$context$data.message) || ''
845
+ message: ((_data$context$data3 = data.context.data) === null || _data$context$data3 === void 0 ? void 0 : _data$context$data3.message) || ''
759
846
  });
760
847
  return;
761
848
  }
@@ -764,6 +851,9 @@ var ComponentApp = /*#__PURE__*/function () {
764
851
  key: 'sdk_onLaunch',
765
852
  value: Date.now()
766
853
  });
854
+ this.AMSSDK.logger.logInfo({
855
+ title: 'sdk_event_webAppOnLaunch'
856
+ }).send();
767
857
  this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
768
858
  this.sendRenderEvent();
769
859
  return;
@@ -814,8 +904,8 @@ var ComponentApp = /*#__PURE__*/function () {
814
904
  }, {
815
905
  key: "handleSizeChanged",
816
906
  value: function handleSizeChanged(data) {
817
- var _data$context$data2;
818
- if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
907
+ var _data$context$data4;
908
+ if (((_data$context$data4 = data.context.data) === null || _data$context$data4 === void 0 ? void 0 : _data$context$data4.height) <= 1) return;
819
909
  var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
820
910
  cashier.style.height = "".concat(data.context.data.height, "px");
821
911
  if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
@@ -1004,8 +1094,11 @@ var ComponentApp = /*#__PURE__*/function () {
1004
1094
  if (targetElement && targetElement.contentWindow) {
1005
1095
  return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
1006
1096
  }
1007
- if (this.app && this.app.contentWindow) {
1008
- return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
1097
+ if (this.app || this.popupApp) {
1098
+ var _this$app, _this$app2, _this$popupApp, _this$popupApp2;
1099
+ (this === null || this === void 0 || (_this$app = this.app) === null || _this$app === void 0 ? void 0 : _this$app.contentWindow) && (this === null || this === void 0 || (_this$app2 = this.app) === null || _this$app2 === void 0 ? void 0 : _this$app2.contentWindow.postMessage(JSON.stringify(data), this.appDomain));
1100
+ (this === null || this === void 0 || (_this$popupApp = this.popupApp) === null || _this$popupApp === void 0 ? void 0 : _this$popupApp.contentWindow) && (this === null || this === void 0 || (_this$popupApp2 = this.popupApp) === null || _this$popupApp2 === void 0 ? void 0 : _this$popupApp2.contentWindow.postMessage(JSON.stringify(data), '*'));
1101
+ return;
1009
1102
  }
1010
1103
  throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
1011
1104
  }
@@ -1031,26 +1124,26 @@ var ComponentApp = /*#__PURE__*/function () {
1031
1124
  }, {
1032
1125
  key: "sendRenderEvent",
1033
1126
  value: function () {
1034
- var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
1127
+ var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1035
1128
  var _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, _this$_renderParams10, res, submitRes;
1036
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1037
- while (1) switch (_context5.prev = _context5.next) {
1129
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1130
+ while (1) switch (_context7.prev = _context7.next) {
1038
1131
  case 0:
1039
- _context5.prev = 0;
1132
+ _context7.prev = 0;
1040
1133
  if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
1041
- _context5.next = 3;
1134
+ _context7.next = 3;
1042
1135
  break;
1043
1136
  }
1044
- return _context5.abrupt("return");
1137
+ return _context7.abrupt("return");
1045
1138
  case 3:
1046
- _context5.next = 5;
1139
+ _context7.next = 5;
1047
1140
  return this._actionQueryPromise;
1048
1141
  case 5:
1049
- res = _context5.sent;
1050
- _context5.next = 8;
1142
+ res = _context7.sent;
1143
+ _context7.next = 8;
1051
1144
  return this._actionSubmitPromise;
1052
1145
  case 8:
1053
- submitRes = _context5.sent;
1146
+ submitRes = _context7.sent;
1054
1147
  this._performanceData.push({
1055
1148
  key: 'sdk_render_component',
1056
1149
  value: Date.now()
@@ -1083,16 +1176,16 @@ var ComponentApp = /*#__PURE__*/function () {
1083
1176
  }
1084
1177
  });
1085
1178
  // eslint-disable-next-line no-empty
1086
- _context5.next = 16;
1179
+ _context7.next = 16;
1087
1180
  break;
1088
1181
  case 14:
1089
- _context5.prev = 14;
1090
- _context5.t0 = _context5["catch"](0);
1182
+ _context7.prev = 14;
1183
+ _context7.t0 = _context7["catch"](0);
1091
1184
  case 16:
1092
1185
  case "end":
1093
- return _context5.stop();
1186
+ return _context7.stop();
1094
1187
  }
1095
- }, _callee5, this, [[0, 14]]);
1188
+ }, _callee7, this, [[0, 14]]);
1096
1189
  }));
1097
1190
  function sendRenderEvent() {
1098
1191
  return _sendRenderEvent.apply(this, arguments);
@@ -1,6 +1,8 @@
1
1
  export declare const insertStyleSheet: () => void;
2
- export declare const createModal: ({ device, url }: {
2
+ export declare const createModal: ({ device, url, widthPadding, heightPadding }: {
3
3
  device: any;
4
4
  url: any;
5
+ widthPadding: any;
6
+ heightPadding: any;
5
7
  }) => HTMLIFrameElement;
6
8
  export declare const destroyModal: () => void;
@@ -13,7 +13,9 @@ export var insertStyleSheet = function insertStyleSheet() {
13
13
  // 插入弹窗
14
14
  export var createModal = function createModal(_ref) {
15
15
  var device = _ref.device,
16
- url = _ref.url;
16
+ url = _ref.url,
17
+ widthPadding = _ref.widthPadding,
18
+ heightPadding = _ref.heightPadding;
17
19
  var overlay = document.createElement('div');
18
20
  overlay.classList.add("".concat(AMSPOPUP_PREFIX, "overlay"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
19
21
  var modal = document.createElement('div');
@@ -23,8 +25,8 @@ export var createModal = function createModal(_ref) {
23
25
  modal.style.height = '464px';
24
26
  modal.style.borderRadius = '12px';
25
27
  } else {
26
- modal.style.width = 'calc(100% - 16px)';
27
- modal.style.height = '80%';
28
+ modal.style.width = "calc(100% - ".concat(2 * widthPadding, "px)");
29
+ modal.style.height = "calc(100% - ".concat(2 * heightPadding, "px)");
28
30
  modal.style.borderRadius = '8px';
29
31
  }
30
32
  var iframe = document.createElement('iframe');
@@ -357,13 +357,6 @@ export declare enum eventCodeEnum {
357
357
  SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
358
358
  SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
359
359
  }
360
- export interface ThreedData {
361
- data: any;
362
- method: string;
363
- targetUrl: string;
364
- pti?: number;
365
- pt?: number;
366
- }
367
360
  export declare enum RedirectType {
368
361
  ApplinkUrl = "ApplinkUrl",
369
362
  SchemeUrl = "SchemeUrl",
@@ -22,6 +22,7 @@ export interface LogMetaData {
22
22
  productSceneVersion?: string;
23
23
  paymentMethodType?: string;
24
24
  paymentMethodCategoryType?: string;
25
+ requestSeq?: string;
25
26
  }
26
27
  interface Config {
27
28
  scriptUrl: string;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@alipay/ams-checkout","version":"1.6.1","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
1
+ {"name":"@alipay/ams-checkout","version":"1.7.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"latest","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","eslint-plugin-prettier":"latest","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}