@alipay/ams-checkout 0.0.1701850681-dev.0 → 0.0.1701850681-dev.5

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.
@@ -164,6 +164,9 @@ export declare const EVENT: {
164
164
  receiveMuitiAppFromSdk: {
165
165
  name: string;
166
166
  };
167
+ getUserAgentFromSdk: {
168
+ name: string;
169
+ };
167
170
  };
168
171
  export declare const COMPONENT_CONTAINER_ID = "ams-component-container";
169
172
  export declare const COMPONENT_SECTION_ID = "ams-component-section";
@@ -163,6 +163,9 @@ export var EVENT = {
163
163
  },
164
164
  receiveMuitiAppFromSdk: {
165
165
  name: 'receiveMuitiAppFromSdk'
166
+ },
167
+ getUserAgentFromSdk: {
168
+ name: 'getUserAgentFromSdk'
166
169
  }
167
170
  };
168
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
  }
@@ -62,6 +62,7 @@ export default class ComponentApp {
62
62
  private resizeListener;
63
63
  private createDialog;
64
64
  private getDeviceIdAndCallback;
65
+ private getUserAgentAndCallback;
65
66
  private returnDataAndCallback;
66
67
  /**
67
68
  * @description Initialize subscription iframe message
@@ -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";
@@ -241,8 +240,11 @@ var ComponentApp = /*#__PURE__*/function () {
241
240
  if ((_renderParams = renderParams) !== null && _renderParams !== void 0 && _renderParams.selector) this._selector = renderParams.selector;
242
241
  this._renderDisplayType = renderParams.renderDisplayType;
243
242
  var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
244
- this.initSecurity();
245
243
  this.initLoggerMeta();
244
+ this.AMSSDK.logger.logInfo({
245
+ title: 'sdk_event_createComponent'
246
+ }).send();
247
+ this.initSecurity();
246
248
  this._performanceData.push({
247
249
  key: 'sdk_create_component',
248
250
  value: Date.now()
@@ -710,12 +712,43 @@ var ComponentApp = /*#__PURE__*/function () {
710
712
  return getDeviceIdAndCallback;
711
713
  }()
712
714
  }, {
713
- key: "returnDataAndCallback",
715
+ key: "getUserAgentAndCallback",
714
716
  value: function () {
715
- var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventContext) {
716
- var _eventContext$data, targetData;
717
+ var _getUserAgentAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventContext) {
717
718
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
718
719
  while (1) switch (_context5.prev = _context5.next) {
720
+ case 0:
721
+ if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
722
+ try {
723
+ this.dispatchToApp({
724
+ context: {
725
+ event: 'appEventCallback',
726
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
727
+ data: {
728
+ userAgent: window.navigator.userAgent + window.location.search // TODO location.search用于模拟配置ua,测试完成后,删除
729
+ }
730
+ }
731
+ });
732
+ } catch (error) {/* empty */}
733
+ }
734
+ case 1:
735
+ case "end":
736
+ return _context5.stop();
737
+ }
738
+ }, _callee5, this);
739
+ }));
740
+ function getUserAgentAndCallback(_x5) {
741
+ return _getUserAgentAndCallback.apply(this, arguments);
742
+ }
743
+ return getUserAgentAndCallback;
744
+ }()
745
+ }, {
746
+ key: "returnDataAndCallback",
747
+ value: function () {
748
+ var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(eventContext) {
749
+ var _eventContext$data, targetData;
750
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
751
+ while (1) switch (_context6.prev = _context6.next) {
719
752
  case 0:
720
753
  if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
721
754
  targetData = this._globalData.get((_eventContext$data = eventContext.data) === null || _eventContext$data === void 0 ? void 0 : _eventContext$data.dataKey);
@@ -729,11 +762,11 @@ var ComponentApp = /*#__PURE__*/function () {
729
762
  }
730
763
  case 1:
731
764
  case "end":
732
- return _context5.stop();
765
+ return _context6.stop();
733
766
  }
734
- }, _callee5, this);
767
+ }, _callee6, this);
735
768
  }));
736
- function returnDataAndCallback(_x5) {
769
+ function returnDataAndCallback(_x6) {
737
770
  return _returnDataAndCallback.apply(this, arguments);
738
771
  }
739
772
  return returnDataAndCallback;
@@ -773,6 +806,10 @@ var ComponentApp = /*#__PURE__*/function () {
773
806
  this.getDeviceIdAndCallback(data.context);
774
807
  return;
775
808
  }
809
+ if (data.context.event === EVENT.getUserAgentFromSdk.name) {
810
+ this.getUserAgentAndCallback(data.context);
811
+ return;
812
+ }
776
813
  if (data.context.event === EVENT.popWindow.name) {
777
814
  destroyModal();
778
815
  return;
@@ -813,6 +850,9 @@ var ComponentApp = /*#__PURE__*/function () {
813
850
  key: 'sdk_onLaunch',
814
851
  value: Date.now()
815
852
  });
853
+ this.AMSSDK.logger.logInfo({
854
+ title: 'sdk_event_webAppOnLaunch'
855
+ }).send();
816
856
  this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
817
857
  this.sendRenderEvent();
818
858
  return;
@@ -1083,26 +1123,26 @@ var ComponentApp = /*#__PURE__*/function () {
1083
1123
  }, {
1084
1124
  key: "sendRenderEvent",
1085
1125
  value: function () {
1086
- var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
1126
+ var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1087
1127
  var _this$_renderParams5, _this$_renderParams6, _this$_renderParams7, _this$_renderParams8, _this$_renderParams9, res, submitRes;
1088
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1089
- while (1) switch (_context6.prev = _context6.next) {
1128
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1129
+ while (1) switch (_context7.prev = _context7.next) {
1090
1130
  case 0:
1091
- _context6.prev = 0;
1131
+ _context7.prev = 0;
1092
1132
  if (!(!this._actionQueryPromise || !this._actionSubmitPromise)) {
1093
- _context6.next = 3;
1133
+ _context7.next = 3;
1094
1134
  break;
1095
1135
  }
1096
- return _context6.abrupt("return");
1136
+ return _context7.abrupt("return");
1097
1137
  case 3:
1098
- _context6.next = 5;
1138
+ _context7.next = 5;
1099
1139
  return this._actionQueryPromise;
1100
1140
  case 5:
1101
- res = _context6.sent;
1102
- _context6.next = 8;
1141
+ res = _context7.sent;
1142
+ _context7.next = 8;
1103
1143
  return this._actionSubmitPromise;
1104
1144
  case 8:
1105
- submitRes = _context6.sent;
1145
+ submitRes = _context7.sent;
1106
1146
  this._performanceData.push({
1107
1147
  key: 'sdk_render_component',
1108
1148
  value: Date.now()
@@ -1135,16 +1175,16 @@ var ComponentApp = /*#__PURE__*/function () {
1135
1175
  }
1136
1176
  });
1137
1177
  // eslint-disable-next-line no-empty
1138
- _context6.next = 16;
1178
+ _context7.next = 16;
1139
1179
  break;
1140
1180
  case 14:
1141
- _context6.prev = 14;
1142
- _context6.t0 = _context6["catch"](0);
1181
+ _context7.prev = 14;
1182
+ _context7.t0 = _context7["catch"](0);
1143
1183
  case 16:
1144
1184
  case "end":
1145
- return _context6.stop();
1185
+ return _context7.stop();
1146
1186
  }
1147
- }, _callee6, this, [[0, 14]]);
1187
+ }, _callee7, this, [[0, 14]]);
1148
1188
  }));
1149
1189
  function sendRenderEvent() {
1150
1190
  return _sendRenderEvent.apply(this, arguments);
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@alipay/ams-checkout","version":"0.0.1701850681-dev.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"}}
1
+ {"name":"@alipay/ams-checkout","version":"0.0.1701850681-dev.5","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"}}