@alipay/ams-checkout 0.0.1732886551-dev.1 → 0.0.1732886551-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.
@@ -82,6 +82,8 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
82
82
|
}
|
83
83
|
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
84
84
|
if (container) container === null || container === void 0 || container.remove();
|
85
|
+
this.webApp = null;
|
86
|
+
this.eventCenter.cleanIFrames();
|
85
87
|
|
86
88
|
// animation
|
87
89
|
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
@@ -27,6 +27,10 @@ export declare class EventCenter implements Service {
|
|
27
27
|
* @param domain - The domain of the app.
|
28
28
|
*/
|
29
29
|
addIFrame(iframe: HTMLIFrameElement): void;
|
30
|
+
/**
|
31
|
+
* Cleans iframes when web app close
|
32
|
+
*/
|
33
|
+
cleanIFrames(): void;
|
30
34
|
removeIFrame(iframe: HTMLIFrameElement): void;
|
31
35
|
/**
|
32
36
|
* Handles messages received from the app.
|
@@ -42,8 +46,9 @@ export declare class EventCenter implements Service {
|
|
42
46
|
* Listens to an event by adding a callback function.
|
43
47
|
* @param name - The name of the event to listen for.
|
44
48
|
* @param func - The callback function to execute when the event is emitted.
|
49
|
+
* @param isAppend - Append to event handlers as chain, default value is false
|
45
50
|
*/
|
46
|
-
listen(name: string, func: IListener): void;
|
51
|
+
listen(name: string, func: IListener, isAppend?: boolean): void;
|
47
52
|
/**
|
48
53
|
* Unsubscribes from an event. If a function is provided, only that function is removed.
|
49
54
|
* @param name - The name of the event to unlisten to.
|
@@ -72,6 +72,15 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
72
72
|
origin: getIframeOrigin(iframe)
|
73
73
|
});
|
74
74
|
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Cleans iframes when web app close
|
78
|
+
*/
|
79
|
+
}, {
|
80
|
+
key: "cleanIFrames",
|
81
|
+
value: function cleanIFrames() {
|
82
|
+
this.iframes = [];
|
83
|
+
}
|
75
84
|
}, {
|
76
85
|
key: "removeIFrame",
|
77
86
|
value: function removeIFrame(iframe) {
|
@@ -99,11 +108,11 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
99
108
|
}
|
100
109
|
var isJson = isJsonString(e.data);
|
101
110
|
if (isJson) {
|
102
|
-
var
|
103
|
-
if (
|
111
|
+
var eventPayload = JSON.parse(e.data);
|
112
|
+
if (eventPayload.name !== MessageName.APP_TO_SDK || eventPayload.instanceId !== this.instanceId) {
|
104
113
|
return;
|
105
114
|
}
|
106
|
-
this._handleAppMessage(
|
115
|
+
this._handleAppMessage(eventPayload);
|
107
116
|
} else {
|
108
117
|
console.error(ERRORMESSAGE.NOT_JSON_FORMAT);
|
109
118
|
}
|
@@ -126,11 +135,13 @@ export var EventCenter = /*#__PURE__*/function () {
|
|
126
135
|
* Listens to an event by adding a callback function.
|
127
136
|
* @param name - The name of the event to listen for.
|
128
137
|
* @param func - The callback function to execute when the event is emitted.
|
138
|
+
* @param isAppend - Append to event handlers as chain, default value is false
|
129
139
|
*/
|
130
140
|
}, {
|
131
141
|
key: "listen",
|
132
142
|
value: function listen(name, func) {
|
133
|
-
var
|
143
|
+
var isAppend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
144
|
+
var eventList = isAppend ? this.events.get(name) || [] : [];
|
134
145
|
eventList.push({
|
135
146
|
func: func
|
136
147
|
});
|
package/esm/index.d.ts
CHANGED
package/esm/index.js
CHANGED