iframe-pubsub 1.0.9 → 1.0.10
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/dist/index.js +3 -10
- package/dist/index.mjs +3 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -125,6 +125,7 @@ var _PubSub = class _PubSub {
|
|
125
125
|
const messageHandler = (event) => {
|
126
126
|
const data = event.data;
|
127
127
|
if (data && data.from === clientId && data.to === "pubsub" && data.payload?.type === "PONG" && data.payload.pingId === pingId) {
|
128
|
+
console.info("Received pong from client:", clientId, data);
|
128
129
|
window.removeEventListener("message", messageHandler);
|
129
130
|
clearTimeout(timeoutId);
|
130
131
|
resolve(true);
|
@@ -139,6 +140,7 @@ var _PubSub = class _PubSub {
|
|
139
140
|
pingId
|
140
141
|
}
|
141
142
|
};
|
143
|
+
console.info("Sending ping to client:", clientId, pingMessage);
|
142
144
|
source.postMessage(pingMessage, "*");
|
143
145
|
const timeoutId = setTimeout(() => {
|
144
146
|
window.removeEventListener("message", messageHandler);
|
@@ -166,16 +168,7 @@ var _PubSub = class _PubSub {
|
|
166
168
|
}
|
167
169
|
if (!data || !data.from || !data.to) return;
|
168
170
|
const message = data;
|
169
|
-
|
170
|
-
await this.mainCallback(message);
|
171
|
-
}
|
172
|
-
const subscriber = this.subscribers.get(message.to);
|
173
|
-
if (!subscriber) return;
|
174
|
-
if (subscriber.source) {
|
175
|
-
subscriber.source.postMessage(message, "*");
|
176
|
-
} else {
|
177
|
-
await subscriber.callback(message);
|
178
|
-
}
|
171
|
+
this.sendMessage(message);
|
179
172
|
}
|
180
173
|
};
|
181
174
|
__publicField(_PubSub, "instance");
|
package/dist/index.mjs
CHANGED
@@ -98,6 +98,7 @@ var _PubSub = class _PubSub {
|
|
98
98
|
const messageHandler = (event) => {
|
99
99
|
const data = event.data;
|
100
100
|
if (data && data.from === clientId && data.to === "pubsub" && data.payload?.type === "PONG" && data.payload.pingId === pingId) {
|
101
|
+
console.info("Received pong from client:", clientId, data);
|
101
102
|
window.removeEventListener("message", messageHandler);
|
102
103
|
clearTimeout(timeoutId);
|
103
104
|
resolve(true);
|
@@ -112,6 +113,7 @@ var _PubSub = class _PubSub {
|
|
112
113
|
pingId
|
113
114
|
}
|
114
115
|
};
|
116
|
+
console.info("Sending ping to client:", clientId, pingMessage);
|
115
117
|
source.postMessage(pingMessage, "*");
|
116
118
|
const timeoutId = setTimeout(() => {
|
117
119
|
window.removeEventListener("message", messageHandler);
|
@@ -139,16 +141,7 @@ var _PubSub = class _PubSub {
|
|
139
141
|
}
|
140
142
|
if (!data || !data.from || !data.to) return;
|
141
143
|
const message = data;
|
142
|
-
|
143
|
-
await this.mainCallback(message);
|
144
|
-
}
|
145
|
-
const subscriber = this.subscribers.get(message.to);
|
146
|
-
if (!subscriber) return;
|
147
|
-
if (subscriber.source) {
|
148
|
-
subscriber.source.postMessage(message, "*");
|
149
|
-
} else {
|
150
|
-
await subscriber.callback(message);
|
151
|
-
}
|
144
|
+
this.sendMessage(message);
|
152
145
|
}
|
153
146
|
};
|
154
147
|
__publicField(_PubSub, "instance");
|