@alipay/ams-checkout 2.0.13 → 2.0.14
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.
- package/ams-checkout.js +3 -3
- package/dist/ams-checkout.min.js +1 -1
- package/esm/core/component/element/EventCenter/index.d.ts +10 -0
- package/esm/core/component/element/EventCenter/index.js +40 -4
- package/esm/core/component/element/elementController/index.d.ts +2 -0
- package/esm/core/component/element/elementController/index.js +29 -2
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +5 -0
- package/esm/modern/index.js +1 -1
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/types.untrimmed.d.ts +4 -0
|
@@ -20,6 +20,16 @@ export declare class EventCenter {
|
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
22
|
endEvent(startId: string, extra?: any): void;
|
|
23
|
+
/**
|
|
24
|
+
* Cancels a single active event and reports it as an ended event with canceled=true.
|
|
25
|
+
* This is used when the mount flow is terminated early (for example, on destroy or abnormal exit).
|
|
26
|
+
*/
|
|
27
|
+
cancelEvent(startId: string, extra?: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Cancels all active events whose event id starts with the given prefix.
|
|
30
|
+
* For example, prefix 'mount' will cancel events like mount_1_start.
|
|
31
|
+
*/
|
|
32
|
+
cancelByPrefix(prefix: string, extra?: any): void;
|
|
23
33
|
private startHeartbeat;
|
|
24
34
|
private stopHeartbeat;
|
|
25
35
|
private sendHeartbeat;
|
|
@@ -89,17 +89,53 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
|
89
89
|
// 如果活动事件数量为0,则停止心跳
|
|
90
90
|
if (this.activeEvents.size === 0) this.stopHeartbeat();
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Cancels a single active event and reports it as an ended event with canceled=true.
|
|
95
|
+
* This is used when the mount flow is terminated early (for example, on destroy or abnormal exit).
|
|
96
|
+
*/
|
|
97
|
+
}, {
|
|
98
|
+
key: "cancelEvent",
|
|
99
|
+
value: function cancelEvent(startId, extra) {
|
|
100
|
+
if (!this.activeEvents.has(startId)) return;
|
|
101
|
+
var startTime = this.activeEvents.get(startId);
|
|
102
|
+
this.activeEvents.delete(startId);
|
|
103
|
+
var type = this.getEventNameFromStart(startId, 'end');
|
|
104
|
+
this.sendLog(type, _objectSpread({
|
|
105
|
+
eventName: this.buildIdFromStart(startId, 'end'),
|
|
106
|
+
startTime: startTime,
|
|
107
|
+
endTime: Date.now(),
|
|
108
|
+
canceled: true
|
|
109
|
+
}, extra || {}));
|
|
110
|
+
if (this.activeEvents.size === 0) this.stopHeartbeat();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Cancels all active events whose event id starts with the given prefix.
|
|
115
|
+
* For example, prefix 'mount' will cancel events like mount_1_start.
|
|
116
|
+
*/
|
|
117
|
+
}, {
|
|
118
|
+
key: "cancelByPrefix",
|
|
119
|
+
value: function cancelByPrefix(prefix, extra) {
|
|
120
|
+
var _this = this;
|
|
121
|
+
var ids = Array.from(this.activeEvents.keys()).filter(function (id) {
|
|
122
|
+
return id.startsWith(prefix);
|
|
123
|
+
});
|
|
124
|
+
ids.forEach(function (id) {
|
|
125
|
+
return _this.cancelEvent(id, extra);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
92
128
|
}, {
|
|
93
129
|
key: "startHeartbeat",
|
|
94
130
|
value: function startHeartbeat() {
|
|
95
|
-
var
|
|
131
|
+
var _this2 = this;
|
|
96
132
|
if (this.heartbeatIntervalId) return;
|
|
97
133
|
this.heartbeatIntervalId = setInterval(function () {
|
|
98
|
-
if (
|
|
99
|
-
|
|
134
|
+
if (_this2.activeEvents.size === 0) {
|
|
135
|
+
_this2.stopHeartbeat();
|
|
100
136
|
return;
|
|
101
137
|
}
|
|
102
|
-
|
|
138
|
+
_this2.sendHeartbeat();
|
|
103
139
|
}, this.HEARTBEAT_INTERVAL);
|
|
104
140
|
}
|
|
105
141
|
}, {
|
|
@@ -20,6 +20,8 @@ declare class ElementController {
|
|
|
20
20
|
private handleInitializationError;
|
|
21
21
|
private handleMountError;
|
|
22
22
|
private clearAndSetInitTimeout;
|
|
23
|
+
private clearInitTimeout;
|
|
24
|
+
private clearEvents;
|
|
23
25
|
private setInitTimeout;
|
|
24
26
|
private initializeAndMountProcessor;
|
|
25
27
|
private handleStartBizFlowError;
|
|
@@ -189,6 +189,25 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
189
189
|
this.initTimeout = this.setInitTimeout(resolve);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
// Clears the pending init timeout to avoid timeout callbacks from stale Element instances.
|
|
193
|
+
}, {
|
|
194
|
+
key: "clearInitTimeout",
|
|
195
|
+
value: function clearInitTimeout() {
|
|
196
|
+
clearTimeout(this.initTimeout);
|
|
197
|
+
this.initTimeout = null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Clears mount-related heartbeat events to avoid stale heartbeat reporting after abnormal exit.
|
|
201
|
+
}, {
|
|
202
|
+
key: "clearEvents",
|
|
203
|
+
value: function clearEvents(reason) {
|
|
204
|
+
var _this$elementEventCen, _this$elementEventCen2;
|
|
205
|
+
// antlog examples: actionName=mount_end&msg=destroy, actionName=mount_end&msg=webLaunch
|
|
206
|
+
(_this$elementEventCen = (_this$elementEventCen2 = this.elementEventCenter).cancelByPrefix) === null || _this$elementEventCen === void 0 || _this$elementEventCen.call(_this$elementEventCen2, 'mount', {
|
|
207
|
+
msg: reason
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
192
211
|
// 设置初始化超时定时器
|
|
193
212
|
}, {
|
|
194
213
|
key: "setInitTimeout",
|
|
@@ -660,18 +679,22 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
660
679
|
_this5.sendReady(key, options);
|
|
661
680
|
});
|
|
662
681
|
}
|
|
663
|
-
_context5.next =
|
|
682
|
+
_context5.next = 26;
|
|
664
683
|
break;
|
|
665
684
|
case 20:
|
|
666
685
|
_context5.prev = 20;
|
|
667
686
|
_context5.t0 = _context5["catch"](1);
|
|
668
687
|
this.handleInitializationError();
|
|
688
|
+
// Fix: when request processing enters the catch path (excluding success=false business responses),
|
|
689
|
+
// stale timeout and heartbeat events must be cleared to avoid duplicate error callbacks.
|
|
690
|
+
this.clearInitTimeout();
|
|
691
|
+
this.clearEvents('webLaunch');
|
|
669
692
|
readyCallback({
|
|
670
693
|
error: _objectSpread(_objectSpread({}, ERRORMESSAGE.INITIALIZE_TIMEOUT.API), {}, {
|
|
671
694
|
traceId: _context5.t0 === null || _context5.t0 === void 0 ? void 0 : _context5.t0.traceId
|
|
672
695
|
})
|
|
673
696
|
});
|
|
674
|
-
case
|
|
697
|
+
case 26:
|
|
675
698
|
case "end":
|
|
676
699
|
return _context5.stop();
|
|
677
700
|
}
|
|
@@ -828,6 +851,10 @@ var ElementController = /*#__PURE__*/function () {
|
|
|
828
851
|
}, {
|
|
829
852
|
key: "destroyHandle",
|
|
830
853
|
value: function destroyHandle() {
|
|
854
|
+
// Fix: when a failed mount is destroyed and a new mount succeeds within the 16s timeout window,
|
|
855
|
+
// clear stale timeout and heartbeat events from the destroyed instance.
|
|
856
|
+
this.clearEvents('destroy');
|
|
857
|
+
this.clearInitTimeout();
|
|
831
858
|
this.elementContainer.destroy();
|
|
832
859
|
cleanMockup();
|
|
833
860
|
removeRetentionPopup();
|
|
@@ -281,6 +281,11 @@ var PaymentProcessor = /*#__PURE__*/function (_BaseElementProcessor) {
|
|
|
281
281
|
}, 100);
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
+
_this3.getLogger().logInfo({
|
|
285
|
+
title: 'sdk_action_query_start'
|
|
286
|
+
}, {
|
|
287
|
+
config: safeStringify(paymentSessionConfig)
|
|
288
|
+
});
|
|
284
289
|
var sdkRequestData = {
|
|
285
290
|
paymentSessionConfig: paymentSessionConfig,
|
|
286
291
|
paymentSessionData: paymentSession,
|
package/esm/modern/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import { createLoader } from '@antglobal/create-sdk-loader';
|
|
|
15
15
|
|
|
16
16
|
import { stageName } from "./stageName";
|
|
17
17
|
var SDKURL = {
|
|
18
|
-
DEV: "https://sdk-dev.marmot-cloud.com/package/ams-checkout/".concat("2.0.
|
|
18
|
+
DEV: "https://sdk-dev.marmot-cloud.com/package/ams-checkout/".concat("2.0.14", "/ams-checkout.js"),
|
|
19
19
|
LOCAL: "http://localhost:3000/ams-checkout.min.js",
|
|
20
20
|
PROD: 'https://js.antom.com/v2/ams-checkout.js'
|
|
21
21
|
};
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -695,6 +695,7 @@ declare interface BaseAppearance<A extends Partial<Appearance>> {
|
|
|
695
695
|
declare interface BaseBridgeEventMap<AppConfig extends Record<string, any> = Record<string, any>, SubmitReplay extends Record<string, any> = Record<string, any>, SubmitParams extends Record<string, any> = Record<string, any>, AppErrorCodes extends string = string, OpenModalConfig extends BaseOpenModalConfig = BaseOpenModalConfig> {
|
|
696
696
|
error: ErrorPayload<AppErrorCodes>;
|
|
697
697
|
/* Excluded from this release type: "OPENSDK@HANDSHAKE" */
|
|
698
|
+
/* Excluded from this release type: "OPENSDK@READY_HANDSHAKE" */
|
|
698
699
|
/* Excluded from this release type: "OPENSDK@UPDATE_CONFIG" */
|
|
699
700
|
/* Excluded from this release type: "OPENSDK@HANDSHAKE_ACK" */
|
|
700
701
|
/* Excluded from this release type: "OPENSDK@SUBMIT" */
|
package/types.untrimmed.d.ts
CHANGED
|
@@ -725,6 +725,10 @@ declare interface BaseBridgeEventMap<AppConfig extends Record<string, any> = Rec
|
|
|
725
725
|
* @internal 内部事件 不暴露给商户
|
|
726
726
|
*/
|
|
727
727
|
"OPENSDK@HANDSHAKE": AppConfig;
|
|
728
|
+
/**
|
|
729
|
+
* @internal 内部事件 不暴露给商户
|
|
730
|
+
*/
|
|
731
|
+
"OPENSDK@READY_HANDSHAKE": void;
|
|
728
732
|
/**
|
|
729
733
|
* @internal 内部事件 不暴露给商户
|
|
730
734
|
*/
|