@laplace.live/ws 7.1.8 → 7.1.9
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/browser.js +13 -4
- package/dist/index.js +18 -5
- package/package.json +5 -5
package/dist/browser.js
CHANGED
|
@@ -1822,7 +1822,7 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
1822
1822
|
super();
|
|
1823
1823
|
this.createConnection = createConnection;
|
|
1824
1824
|
this.closed = false;
|
|
1825
|
-
this.interval =
|
|
1825
|
+
this.interval = 3e3;
|
|
1826
1826
|
this.timeout = 45 * 1e3;
|
|
1827
1827
|
this.connection = this.createConnection();
|
|
1828
1828
|
this.connect(false);
|
|
@@ -1836,8 +1836,9 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
1836
1836
|
*/
|
|
1837
1837
|
connect(reconnect = true) {
|
|
1838
1838
|
if (reconnect) {
|
|
1839
|
-
this.connection
|
|
1839
|
+
const old = this.connection;
|
|
1840
1840
|
this.connection = this.createConnection();
|
|
1841
|
+
old.close();
|
|
1841
1842
|
}
|
|
1842
1843
|
const connection = this.connection;
|
|
1843
1844
|
let timeout = setTimeout(() => {
|
|
@@ -1845,6 +1846,7 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
1845
1846
|
connection.dispatchEvent(new Event("timeout"));
|
|
1846
1847
|
}, this.timeout);
|
|
1847
1848
|
connection.addEventListener("event", (e) => {
|
|
1849
|
+
if (this.connection !== connection) return;
|
|
1848
1850
|
const evt = e.data;
|
|
1849
1851
|
if (evt.type !== "error") {
|
|
1850
1852
|
if (evt instanceof LaplaceRawEvent) {
|
|
@@ -1856,11 +1858,12 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
1856
1858
|
});
|
|
1857
1859
|
connection.addEventListener("error", () => this.dispatchEvent(new Event("e")));
|
|
1858
1860
|
connection.addEventListener("close", () => {
|
|
1859
|
-
if (!this.closed) {
|
|
1861
|
+
if (!this.closed && this.connection === connection) {
|
|
1860
1862
|
setTimeout(() => this.connect(), this.interval);
|
|
1861
1863
|
}
|
|
1862
1864
|
});
|
|
1863
1865
|
connection.addEventListener("heartbeat", () => {
|
|
1866
|
+
if (this.connection !== connection) return;
|
|
1864
1867
|
clearTimeout(timeout);
|
|
1865
1868
|
timeout = setTimeout(() => {
|
|
1866
1869
|
connection.close();
|
|
@@ -2026,8 +2029,10 @@ var Live = class extends LaplaceEventTarget {
|
|
|
2026
2029
|
}, 0);
|
|
2027
2030
|
this.send = send;
|
|
2028
2031
|
this.close = () => {
|
|
2032
|
+
if (this.closed) return;
|
|
2029
2033
|
this.closed = true;
|
|
2030
2034
|
close();
|
|
2035
|
+
this.dispatchEvent(new Event("close"));
|
|
2031
2036
|
};
|
|
2032
2037
|
const decode = makeDecoder(inflates2);
|
|
2033
2038
|
this.addEventListener("message", async (e) => {
|
|
@@ -2108,7 +2113,11 @@ var LiveWSBase = class extends Live {
|
|
|
2108
2113
|
ws.binaryType = "arraybuffer";
|
|
2109
2114
|
ws.addEventListener("open", (e) => this.dispatchEvent(new Event(e.type)));
|
|
2110
2115
|
ws.addEventListener("message", (e) => this.dispatchEvent(new LaplaceRawEvent("message", new Uint8Array(e.data))));
|
|
2111
|
-
ws.addEventListener("close", (e) =>
|
|
2116
|
+
ws.addEventListener("close", (e) => {
|
|
2117
|
+
if (!this.closed) {
|
|
2118
|
+
this.dispatchEvent(new Event(e.type));
|
|
2119
|
+
}
|
|
2120
|
+
});
|
|
2112
2121
|
ws.addEventListener("error", () => this.dispatchEvent(new Event("_error")));
|
|
2113
2122
|
this.ws = ws;
|
|
2114
2123
|
}
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
39
39
|
super();
|
|
40
40
|
this.createConnection = createConnection;
|
|
41
41
|
this.closed = false;
|
|
42
|
-
this.interval =
|
|
42
|
+
this.interval = 3e3;
|
|
43
43
|
this.timeout = 45 * 1e3;
|
|
44
44
|
this.connection = this.createConnection();
|
|
45
45
|
this.connect(false);
|
|
@@ -53,8 +53,9 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
53
53
|
*/
|
|
54
54
|
connect(reconnect = true) {
|
|
55
55
|
if (reconnect) {
|
|
56
|
-
this.connection
|
|
56
|
+
const old = this.connection;
|
|
57
57
|
this.connection = this.createConnection();
|
|
58
|
+
old.close();
|
|
58
59
|
}
|
|
59
60
|
const connection = this.connection;
|
|
60
61
|
let timeout = setTimeout(() => {
|
|
@@ -62,6 +63,7 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
62
63
|
connection.dispatchEvent(new Event("timeout"));
|
|
63
64
|
}, this.timeout);
|
|
64
65
|
connection.addEventListener("event", (e) => {
|
|
66
|
+
if (this.connection !== connection) return;
|
|
65
67
|
const evt = e.data;
|
|
66
68
|
if (evt.type !== "error") {
|
|
67
69
|
if (evt instanceof LaplaceRawEvent) {
|
|
@@ -73,11 +75,12 @@ var KeepLive = class extends LaplaceEventTarget {
|
|
|
73
75
|
});
|
|
74
76
|
connection.addEventListener("error", () => this.dispatchEvent(new Event("e")));
|
|
75
77
|
connection.addEventListener("close", () => {
|
|
76
|
-
if (!this.closed) {
|
|
78
|
+
if (!this.closed && this.connection === connection) {
|
|
77
79
|
setTimeout(() => this.connect(), this.interval);
|
|
78
80
|
}
|
|
79
81
|
});
|
|
80
82
|
connection.addEventListener("heartbeat", () => {
|
|
83
|
+
if (this.connection !== connection) return;
|
|
81
84
|
clearTimeout(timeout);
|
|
82
85
|
timeout = setTimeout(() => {
|
|
83
86
|
connection.close();
|
|
@@ -246,8 +249,10 @@ var Live = class extends LaplaceEventTarget {
|
|
|
246
249
|
}, 0);
|
|
247
250
|
this.send = send;
|
|
248
251
|
this.close = () => {
|
|
252
|
+
if (this.closed) return;
|
|
249
253
|
this.closed = true;
|
|
250
254
|
close();
|
|
255
|
+
this.dispatchEvent(new Event("close"));
|
|
251
256
|
};
|
|
252
257
|
const decode = makeDecoder(inflates2);
|
|
253
258
|
this.addEventListener("message", async (e) => {
|
|
@@ -330,7 +335,11 @@ var LiveTCPBase = class extends Live {
|
|
|
330
335
|
this.i = 0;
|
|
331
336
|
this.buf = Buffer.alloc(0);
|
|
332
337
|
socket.on("ready", () => this.dispatchEvent(new Event("open")));
|
|
333
|
-
socket.on("close", () =>
|
|
338
|
+
socket.on("close", () => {
|
|
339
|
+
if (!this.closed) {
|
|
340
|
+
this.dispatchEvent(new Event("close"));
|
|
341
|
+
}
|
|
342
|
+
});
|
|
334
343
|
socket.on("error", () => this.dispatchEvent(new Event("_error")));
|
|
335
344
|
socket.on("data", (buffer) => {
|
|
336
345
|
this.buf = Buffer.concat([this.buf, buffer]);
|
|
@@ -375,7 +384,11 @@ var LiveWSBase = class extends Live {
|
|
|
375
384
|
ws.binaryType = "arraybuffer";
|
|
376
385
|
ws.addEventListener("open", (e) => this.dispatchEvent(new Event(e.type)));
|
|
377
386
|
ws.addEventListener("message", (e) => this.dispatchEvent(new LaplaceRawEvent("message", new Uint8Array(e.data))));
|
|
378
|
-
ws.addEventListener("close", (e) =>
|
|
387
|
+
ws.addEventListener("close", (e) => {
|
|
388
|
+
if (!this.closed) {
|
|
389
|
+
this.dispatchEvent(new Event(e.type));
|
|
390
|
+
}
|
|
391
|
+
});
|
|
379
392
|
ws.addEventListener("error", () => this.dispatchEvent(new Event("_error")));
|
|
380
393
|
this.ws = ws;
|
|
381
394
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laplace.live/ws",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.9",
|
|
4
4
|
"description": "LAPLACE Live! flavored bilibili live WebSocket/TCP API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"provenance": true
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@laplace.live/internal": "^1.3.
|
|
65
|
+
"@laplace.live/internal": "^1.3.7"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@biomejs/biome": "^2.4.
|
|
68
|
+
"@biomejs/biome": "^2.4.12",
|
|
69
69
|
"@changesets/cli": "^2.30.0",
|
|
70
|
-
"@types/bun": "^1.3.
|
|
71
|
-
"playwright": "^1.
|
|
70
|
+
"@types/bun": "^1.3.12",
|
|
71
|
+
"playwright": "^1.59.1",
|
|
72
72
|
"tsup": "^8.5.1",
|
|
73
73
|
"typescript": "^5.9.3"
|
|
74
74
|
}
|