@sandbox-engine/sdk 0.2.4 → 0.2.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.
- package/dist/index.js +9 -5
- package/dist/index.mjs +9 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -46,17 +46,21 @@ var WsEmitterAdapter = class extends import_node_events.EventEmitter {
|
|
|
46
46
|
super();
|
|
47
47
|
this.ws = ws;
|
|
48
48
|
ws.accept?.();
|
|
49
|
+
let openFired = false;
|
|
50
|
+
const emitOpen = () => {
|
|
51
|
+
if (!openFired) {
|
|
52
|
+
openFired = true;
|
|
53
|
+
this.emit("open");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
49
56
|
ws.addEventListener("message", (e) => {
|
|
50
57
|
const raw = e.data;
|
|
51
58
|
this.emit("message", typeof raw === "string" ? raw : String(raw));
|
|
52
59
|
});
|
|
53
60
|
ws.addEventListener("error", (e) => this.emit("error", e));
|
|
54
61
|
ws.addEventListener("close", () => this.emit("close"));
|
|
55
|
-
ws.addEventListener("open",
|
|
56
|
-
|
|
57
|
-
if (state === 1) {
|
|
58
|
-
queueMicrotask(() => this.emit("open"));
|
|
59
|
-
}
|
|
62
|
+
ws.addEventListener("open", emitOpen);
|
|
63
|
+
queueMicrotask(emitOpen);
|
|
60
64
|
}
|
|
61
65
|
ws;
|
|
62
66
|
OPEN = 1;
|
package/dist/index.mjs
CHANGED
|
@@ -5,17 +5,21 @@ var WsEmitterAdapter = class extends EventEmitter {
|
|
|
5
5
|
super();
|
|
6
6
|
this.ws = ws;
|
|
7
7
|
ws.accept?.();
|
|
8
|
+
let openFired = false;
|
|
9
|
+
const emitOpen = () => {
|
|
10
|
+
if (!openFired) {
|
|
11
|
+
openFired = true;
|
|
12
|
+
this.emit("open");
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
ws.addEventListener("message", (e) => {
|
|
9
16
|
const raw = e.data;
|
|
10
17
|
this.emit("message", typeof raw === "string" ? raw : String(raw));
|
|
11
18
|
});
|
|
12
19
|
ws.addEventListener("error", (e) => this.emit("error", e));
|
|
13
20
|
ws.addEventListener("close", () => this.emit("close"));
|
|
14
|
-
ws.addEventListener("open",
|
|
15
|
-
|
|
16
|
-
if (state === 1) {
|
|
17
|
-
queueMicrotask(() => this.emit("open"));
|
|
18
|
-
}
|
|
21
|
+
ws.addEventListener("open", emitOpen);
|
|
22
|
+
queueMicrotask(emitOpen);
|
|
19
23
|
}
|
|
20
24
|
ws;
|
|
21
25
|
OPEN = 1;
|