cross-tab-worker-databus 0.20.60 → 0.20.61
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 +14 -1
- package/dist/centrifuge.js +1 -1
- package/dist/{chunk-KLHPSFVU.js → chunk-VB4P6DS6.js} +14 -9
- package/dist/chunk-VB4P6DS6.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +13 -8
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +13 -8
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts +9 -4
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/core/types.d.ts +10 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/docs/roadmap.md +8 -1
- package/docs/zh/roadmap.md +8 -1
- package/package.json +1 -1
- package/dist/chunk-KLHPSFVU.js.map +0 -7
package/dist/cjs/centrifuge.cjs
CHANGED
|
@@ -677,9 +677,12 @@ var WorkerClusterRuntime = class {
|
|
|
677
677
|
routeOwnerIsLive(route, workers) {
|
|
678
678
|
return Boolean(route && workers.some((worker) => worker.workerId === route.workerId));
|
|
679
679
|
}
|
|
680
|
-
/** Broadcast an event to every tab — used to fan out transport publications.
|
|
681
|
-
|
|
682
|
-
|
|
680
|
+
/** Broadcast an event to every tab — used to fan out transport publications.
|
|
681
|
+
* `originTabId` (when set) is propagated across the BroadcastChannel hop so
|
|
682
|
+
* listeners can attribute the event to its source tab even after fan-out. */
|
|
683
|
+
broadcastEvent(eventType, payload, originTabId) {
|
|
684
|
+
const effectiveOriginTabId = originTabId ?? this.tabId;
|
|
685
|
+
this.send({ type: "EVENT", sourceWorkerId: this.workerId, eventType, payload, originTabId: effectiveOriginTabId });
|
|
683
686
|
}
|
|
684
687
|
isAssigned(topic) {
|
|
685
688
|
const topicKey = createOpaqueKey(topic);
|
|
@@ -767,7 +770,7 @@ var WorkerClusterRuntime = class {
|
|
|
767
770
|
case "ROUTE_RELEASED":
|
|
768
771
|
return this.handleRouteReleasedMessage(message);
|
|
769
772
|
case "EVENT":
|
|
770
|
-
this.handlers.onEvent(message.eventType, message.payload, message.sourceWorkerId);
|
|
773
|
+
this.handlers.onEvent(message.eventType, message.payload, message.sourceWorkerId, message.originTabId);
|
|
771
774
|
return;
|
|
772
775
|
case "REGISTRY":
|
|
773
776
|
default:
|
|
@@ -1519,9 +1522,10 @@ var CrossTabDataBus = class {
|
|
|
1519
1522
|
// typed `unknown` at the cluster boundary (the cluster is transport-
|
|
1520
1523
|
// agnostic); here we narrow it to DataBusMessage — the sender is our
|
|
1521
1524
|
// own broadcastEvent call, which always posts a DataBusMessage.
|
|
1522
|
-
onEvent: (eventType, payload) => {
|
|
1525
|
+
onEvent: (eventType, payload, _sourceWorkerId, originTabId) => {
|
|
1523
1526
|
if (eventType !== PUBLICATION_EVENT) return;
|
|
1524
|
-
const
|
|
1527
|
+
const incoming = payload;
|
|
1528
|
+
const message = incoming.originTabId !== void 0 ? incoming : originTabId !== void 0 ? { ...incoming, originTabId } : incoming;
|
|
1525
1529
|
if (this.cluster.hasLocalSubscriber(message.topic)) this.dispatch(message);
|
|
1526
1530
|
},
|
|
1527
1531
|
onSuspend: () => {
|
|
@@ -1884,9 +1888,10 @@ var CrossTabDataBus = class {
|
|
|
1884
1888
|
this.trace.recordDiscarded(message.topic);
|
|
1885
1889
|
return;
|
|
1886
1890
|
}
|
|
1887
|
-
this.cluster.
|
|
1891
|
+
const stamped = message.originTabId === void 0 ? { ...message, originTabId: this.cluster.tabId } : message;
|
|
1892
|
+
this.cluster.broadcastEvent(PUBLICATION_EVENT, stamped, stamped.originTabId);
|
|
1888
1893
|
if (this.cluster.hasLocalSubscriber(message.topic)) {
|
|
1889
|
-
this.dispatch(
|
|
1894
|
+
this.dispatch(stamped);
|
|
1890
1895
|
return;
|
|
1891
1896
|
}
|
|
1892
1897
|
this.trace.recordDiscarded(message.topic);
|