cross-tab-worker-databus 0.20.89 → 0.20.91
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/CHANGELOG.md +23 -0
- package/dist/centrifuge-session.d.ts.map +1 -1
- package/dist/centrifuge.js +7 -9
- package/dist/centrifuge.js.map +2 -2
- package/dist/centrifuge.shared.worker.js +6 -8
- package/dist/centrifuge.shared.worker.js.map +2 -2
- package/dist/centrifuge.worker.js +6 -8
- package/dist/centrifuge.worker.js.map +2 -2
- package/dist/{chunk-77BQELW4.js → chunk-DMM5KBNG.js} +9 -6
- package/dist/chunk-DMM5KBNG.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +14 -13
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +18 -6
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +2 -2
- package/dist/websocket.d.ts +3 -0
- package/dist/websocket.d.ts.map +1 -1
- package/docs/api.md +1 -1
- package/docs/architecture.md +7 -3
- package/docs/benchmarks.md +7 -7
- package/docs/capabilities.md +1 -1
- package/docs/release-checklist.md +2 -2
- package/docs/roadmap.md +19 -2
- package/docs/zh/api.md +2 -0
- package/docs/zh/architecture.md +7 -3
- package/docs/zh/benchmarks.md +7 -7
- package/docs/zh/capabilities.md +1 -1
- package/docs/zh/release-checklist.md +2 -2
- package/docs/zh/roadmap.md +19 -2
- package/package.json +1 -1
- package/dist/chunk-77BQELW4.js.map +0 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -849,10 +849,12 @@ var WorkerClusterRuntime = class {
|
|
|
849
849
|
const channel = this.channel;
|
|
850
850
|
this.channel = null;
|
|
851
851
|
this.handlers.onSuspend?.();
|
|
852
|
-
if (
|
|
853
|
-
globalThis.setTimeout
|
|
854
|
-
|
|
855
|
-
|
|
852
|
+
if (channel) {
|
|
853
|
+
if (typeof globalThis.setTimeout === "function") {
|
|
854
|
+
globalThis.setTimeout(() => channel.close(), 0);
|
|
855
|
+
} else {
|
|
856
|
+
channel.close();
|
|
857
|
+
}
|
|
856
858
|
}
|
|
857
859
|
}
|
|
858
860
|
/** Update the worker's connection status and persist the change. */
|
|
@@ -2336,7 +2338,7 @@ var DedupManager = class {
|
|
|
2336
2338
|
};
|
|
2337
2339
|
|
|
2338
2340
|
// src/core/version.ts
|
|
2339
|
-
var SDK_VERSION = true ? "0.20.
|
|
2341
|
+
var SDK_VERSION = true ? "0.20.91" : "";
|
|
2340
2342
|
|
|
2341
2343
|
// src/core/data-bus.ts
|
|
2342
2344
|
var DEFAULT_REPLAY_MAX_PER_TOPIC = 100;
|
|
@@ -2518,6 +2520,7 @@ var CrossTabDataBus = class {
|
|
|
2518
2520
|
// own broadcastEvent call, which always posts a DataBusMessage.
|
|
2519
2521
|
onEvent: (eventType, payload, _sourceWorkerId, originTabId) => {
|
|
2520
2522
|
if (eventType !== PUBLICATION_EVENT) return;
|
|
2523
|
+
if (typeof payload !== "object" || payload === null || typeof payload.topic !== "string") return;
|
|
2521
2524
|
const incoming = payload;
|
|
2522
2525
|
const message = incoming.originTabId !== void 0 ? incoming : originTabId !== void 0 ? { ...incoming, originTabId } : incoming;
|
|
2523
2526
|
if (this.cluster.hasLocalSubscriber(message.topic)) this.dispatch(message);
|
|
@@ -3769,7 +3772,7 @@ var WebSocketTransport = class {
|
|
|
3769
3772
|
handlers.onStatus(WORKER_STATUS.ERROR);
|
|
3770
3773
|
handlers.onError(error);
|
|
3771
3774
|
this.failConnect(error);
|
|
3772
|
-
|
|
3775
|
+
this.abortSocket(socket);
|
|
3773
3776
|
}, timeoutMs);
|
|
3774
3777
|
}
|
|
3775
3778
|
socket.onopen = () => {
|
|
@@ -3802,6 +3805,7 @@ var WebSocketTransport = class {
|
|
|
3802
3805
|
handshakeFailed = true;
|
|
3803
3806
|
this.failConnect(new Error("WebSocket failed to open."));
|
|
3804
3807
|
}
|
|
3808
|
+
this.abortSocket(socket);
|
|
3805
3809
|
};
|
|
3806
3810
|
socket.onmessage = (event) => {
|
|
3807
3811
|
if (this.socket === socket && this.handlers === handlers && this.socketActive) {
|
|
@@ -3895,6 +3899,14 @@ var WebSocketTransport = class {
|
|
|
3895
3899
|
this.connectReject = null;
|
|
3896
3900
|
reject?.(error);
|
|
3897
3901
|
}
|
|
3902
|
+
/** Best-effort close for a socket that can no longer carry transport data.
|
|
3903
|
+
* The error that invalidated it has already been reported by the caller. */
|
|
3904
|
+
abortSocket(socket) {
|
|
3905
|
+
try {
|
|
3906
|
+
socket.close();
|
|
3907
|
+
} catch {
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3898
3910
|
clearConnectTimer() {
|
|
3899
3911
|
if (this.connectTimer !== null) {
|
|
3900
3912
|
clearTimeout(this.connectTimer);
|