@alipay/ams-checkout 0.0.1738831627-dev.4 → 0.0.1738831627-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.
@@ -28,6 +28,7 @@ import { ElementPaymentComponent } from "./components/payment";
|
|
28
28
|
import { v4 as uuid } from 'uuid';
|
29
29
|
import { LogConfig, Logger } from "../../../util/logger";
|
30
30
|
import { addressTheme, ElementPaymentEvent, ElementPaymentMethod, ElementType, ELEMENT_ENVIRONMENT, EventCallbackCode, ThemeType, MountElementType } from "./type";
|
31
|
+
import { destroyModal } from "../../../plugin/component/popupWindow.style";
|
31
32
|
var logger = new Logger(LogConfig, true);
|
32
33
|
var ElementProcessor = /*#__PURE__*/function () {
|
33
34
|
function ElementProcessor(options) {
|
@@ -577,6 +578,14 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
577
578
|
this.eventService.listen(ConstantEvent.redirect.name, function (data, res) {
|
578
579
|
data.isDestroy && _this6.unmount();
|
579
580
|
});
|
581
|
+
this.eventService.listen('appHeartBeat', function (result) {
|
582
|
+
var _this6$_options$loadi;
|
583
|
+
if (_this6.loading && (_this6$_options$loadi = _this6._options.loading) !== null && _this6$_options$loadi !== void 0 && _this6$_options$loadi.onEndLoading) {
|
584
|
+
var _this6$_options$loadi2, _this6$_options$loadi3;
|
585
|
+
(_this6$_options$loadi2 = _this6._options.loading) === null || _this6$_options$loadi2 === void 0 || (_this6$_options$loadi3 = _this6$_options$loadi2.onEndLoading) === null || _this6$_options$loadi3 === void 0 || _this6$_options$loadi3.call(_this6$_options$loadi2);
|
586
|
+
}
|
587
|
+
_this6.loading = false;
|
588
|
+
});
|
580
589
|
|
581
590
|
// this.eventService.listen(ElementPaymentEvent.LOG, (result: EventCallbackData) => {
|
582
591
|
// console.log('antom sdk 组件日志回调');
|
@@ -603,15 +612,10 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
603
612
|
}, {
|
604
613
|
key: "showIframe",
|
605
614
|
value: function showIframe() {
|
606
|
-
var _this$paymentBase, _this$addressBase, _this$authBase
|
607
|
-
this.loading = false;
|
615
|
+
var _this$paymentBase, _this$addressBase, _this$authBase;
|
608
616
|
(this === null || this === void 0 ? void 0 : this.paymentBase) && (this === null || this === void 0 || (_this$paymentBase = this.paymentBase) === null || _this$paymentBase === void 0 ? void 0 : _this$paymentBase.update());
|
609
617
|
(this === null || this === void 0 ? void 0 : this.addressBase) && (this === null || this === void 0 || (_this$addressBase = this.addressBase) === null || _this$addressBase === void 0 ? void 0 : _this$addressBase.update());
|
610
618
|
(this === null || this === void 0 ? void 0 : this.authBase) && (this === null || this === void 0 || (_this$authBase = this.authBase) === null || _this$authBase === void 0 ? void 0 : _this$authBase.update());
|
611
|
-
if ((_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onEndLoading) {
|
612
|
-
var _this$_options$loadin2, _this$_options$loadin3;
|
613
|
-
(_this$_options$loadin2 = this._options.loading) === null || _this$_options$loadin2 === void 0 || (_this$_options$loadin3 = _this$_options$loadin2.onEndLoading) === null || _this$_options$loadin3 === void 0 || _this$_options$loadin3.call(_this$_options$loadin2);
|
614
|
-
}
|
615
619
|
}
|
616
620
|
}, {
|
617
621
|
key: "afterInit",
|
@@ -731,21 +735,21 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
731
735
|
title: 'sdk_element_mount_start'
|
732
736
|
});
|
733
737
|
if (typeof sdkSelector === 'string') {
|
734
|
-
var _this$_options$
|
738
|
+
var _this$_options$loadin, _renderOptions$debugP, _renderOptions$debugP2;
|
735
739
|
var element = document.querySelector(sdkSelector);
|
736
740
|
if (!element) {
|
737
741
|
throw Error("Loading failed, you need to check if the element exists.");
|
738
742
|
}
|
739
743
|
this.componentsCount = this.componentsCount + 1;
|
740
|
-
if (!this.loading && (_this$_options$
|
741
|
-
var _this$_options$
|
742
|
-
(_this$_options$
|
744
|
+
if (!this.loading && (_this$_options$loadin = this._options.loading) !== null && _this$_options$loadin !== void 0 && _this$_options$loadin.onStartLoading && renderOptions.type === ElementType.payment) {
|
745
|
+
var _this$_options$loadin2, _this$_options$loadin3;
|
746
|
+
(_this$_options$loadin2 = this._options.loading) === null || _this$_options$loadin2 === void 0 || (_this$_options$loadin3 = _this$_options$loadin2.onStartLoading) === null || _this$_options$loadin3 === void 0 || _this$_options$loadin3.call(_this$_options$loadin2);
|
743
747
|
}
|
748
|
+
this.loading = true;
|
744
749
|
var elementLink = renderOptions !== null && renderOptions !== void 0 && (_renderOptions$debugP = renderOptions.debugProps) !== null && _renderOptions$debugP !== void 0 && _renderOptions$debugP.localLink ? renderOptions === null || renderOptions === void 0 || (_renderOptions$debugP2 = renderOptions.debugProps) === null || _renderOptions$debugP2 === void 0 ? void 0 : _renderOptions$debugP2.localLink : this.iframeSrc[renderOptions.type];
|
745
750
|
renderOptions.elementProps = {
|
746
751
|
elementLink: elementLink
|
747
752
|
};
|
748
|
-
this.loading = true;
|
749
753
|
if (renderOptions.type === ElementType.auth) {
|
750
754
|
return this.mountAuth(renderOptions, sdkSelector);
|
751
755
|
}
|
@@ -780,6 +784,13 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
780
784
|
key: "unmount",
|
781
785
|
value: function unmount() {
|
782
786
|
var _this$authBase2, _this$authBase2$unmou, _this$addressBase2, _this$addressBase2$un, _this$paymentBase2, _this$paymentBase2$un;
|
787
|
+
if (!this.iframes.PAYMENT_ELEMENT) {
|
788
|
+
throw Error("Component is not mounted. You need to check if the mount method has been successfully called to mount the component.");
|
789
|
+
}
|
790
|
+
// popup未注册会报错,但element不需要感知popup是否被注册
|
791
|
+
try {
|
792
|
+
destroyModal(); // 关闭popup弹窗
|
793
|
+
} catch (error) {}
|
783
794
|
(_this$authBase2 = this.authBase) === null || _this$authBase2 === void 0 || (_this$authBase2$unmou = _this$authBase2.unmount) === null || _this$authBase2$unmou === void 0 || _this$authBase2$unmou.call(_this$authBase2);
|
784
795
|
(_this$addressBase2 = this.addressBase) === null || _this$addressBase2 === void 0 || (_this$addressBase2$un = _this$addressBase2.unmount) === null || _this$addressBase2$un === void 0 || _this$addressBase2$un.call(_this$addressBase2);
|
785
796
|
(_this$paymentBase2 = this.paymentBase) === null || _this$paymentBase2 === void 0 || (_this$paymentBase2$un = _this$paymentBase2.unmount) === null || _this$paymentBase2$un === void 0 || _this$paymentBase2$un.call(_this$paymentBase2);
|
@@ -795,8 +806,8 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
795
806
|
value: // 暴露出去的submit方法
|
796
807
|
function () {
|
797
808
|
var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
798
|
-
var _this$_options$
|
799
|
-
var _this$_options$
|
809
|
+
var _this$_options$loadin4, _this$_options$loadin7;
|
810
|
+
var _this$_options$loadin5, _this$_options$loadin6, _this$_options$loadin8, _this$_options$loadin9;
|
800
811
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
801
812
|
while (1) switch (_context2.prev = _context2.next) {
|
802
813
|
case 0:
|
@@ -806,17 +817,25 @@ export var ElementComponent = /*#__PURE__*/function () {
|
|
806
817
|
}
|
807
818
|
throw Error("Component is not mounted. You need to check if the mount method has been successfully called to mount the component.");
|
808
819
|
case 2:
|
809
|
-
if (
|
810
|
-
|
820
|
+
if (!this.loading) {
|
821
|
+
_context2.next = 4;
|
822
|
+
break;
|
823
|
+
}
|
824
|
+
throw Error("The form is submitted repeatedly. without the need to click submit repeatedly.");
|
825
|
+
case 4:
|
826
|
+
if ((_this$_options$loadin4 = this._options.loading) !== null && _this$_options$loadin4 !== void 0 && _this$_options$loadin4.onStartLoading) {
|
827
|
+
(_this$_options$loadin5 = this._options.loading) === null || _this$_options$loadin5 === void 0 || (_this$_options$loadin6 = _this$_options$loadin5.onStartLoading) === null || _this$_options$loadin6 === void 0 || _this$_options$loadin6.call(_this$_options$loadin5);
|
811
828
|
}
|
812
|
-
|
829
|
+
this.loading = true;
|
830
|
+
_context2.next = 8;
|
813
831
|
return this.validatePromiseFuncs();
|
814
|
-
case
|
815
|
-
|
816
|
-
|
832
|
+
case 8:
|
833
|
+
this.loading = false;
|
834
|
+
if ((_this$_options$loadin7 = this._options.loading) !== null && _this$_options$loadin7 !== void 0 && _this$_options$loadin7.onEndLoading) {
|
835
|
+
(_this$_options$loadin8 = this._options.loading) === null || _this$_options$loadin8 === void 0 || (_this$_options$loadin9 = _this$_options$loadin8.onEndLoading) === null || _this$_options$loadin9 === void 0 || _this$_options$loadin9.call(_this$_options$loadin8);
|
817
836
|
}
|
818
837
|
return _context2.abrupt("return");
|
819
|
-
case
|
838
|
+
case 11:
|
820
839
|
case "end":
|
821
840
|
return _context2.stop();
|
822
841
|
}
|
package/esm/types/index.d.ts
CHANGED
@@ -6,7 +6,7 @@
|
|
6
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.
|
7
7
|
*/
|
8
8
|
export type onChange = () => onCnageResult;
|
9
|
-
export type
|
9
|
+
export { type IElementOptions, ElementType, ThemeType, PaymentElementLayout } from '../core/component/element/type';
|
10
10
|
interface onCnageResult {
|
11
11
|
complete: boolean;
|
12
12
|
addressValue: AddressItem[];
|
package/esm/types/index.js
CHANGED