cross-tab-worker-databus 0.21.23 → 0.21.25
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 +46 -0
- package/dist/centrifuge.js +1 -1
- package/dist/{chunk-UT4ZYUW4.js → chunk-ORGPJ2CX.js} +19 -6
- package/dist/chunk-ORGPJ2CX.js.map +7 -0
- package/dist/cjs/centrifuge.cjs +18 -5
- package/dist/cjs/centrifuge.cjs.map +2 -2
- package/dist/cjs/index.cjs +18 -5
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/data-bus.d.ts +3 -1
- package/dist/core/data-bus.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/docs/api.md +3 -0
- package/docs/roadmap.md +16 -1
- package/docs/zh/api.md +3 -0
- package/docs/zh/roadmap.md +16 -1
- package/package.json +1 -1
- package/dist/chunk-UT4ZYUW4.js.map +0 -7
package/dist/cjs/centrifuge.cjs
CHANGED
|
@@ -871,7 +871,7 @@ var WorkerClusterRuntime = class {
|
|
|
871
871
|
*/
|
|
872
872
|
stop() {
|
|
873
873
|
this.lifecycleGeneration += 1;
|
|
874
|
-
if (!this.started && !this.suspended) return;
|
|
874
|
+
if (!this.started && !this.suspended && !this.lifecycleListening) return;
|
|
875
875
|
this.pause();
|
|
876
876
|
this.flushStorage();
|
|
877
877
|
this.removeLifecycleListeners();
|
|
@@ -899,6 +899,12 @@ var WorkerClusterRuntime = class {
|
|
|
899
899
|
this.channel = null;
|
|
900
900
|
}
|
|
901
901
|
if (!this.channel) this.storage = null;
|
|
902
|
+
if (!this.started) {
|
|
903
|
+
const channel = this.channel;
|
|
904
|
+
this.channel = null;
|
|
905
|
+
channel?.close();
|
|
906
|
+
return;
|
|
907
|
+
}
|
|
902
908
|
this.channel?.addEventListener("message", this.handleMessage);
|
|
903
909
|
const now = this.environment.now();
|
|
904
910
|
this.currentRecord = {
|
|
@@ -914,6 +920,7 @@ var WorkerClusterRuntime = class {
|
|
|
914
920
|
if (!this.storage) this.sendControl(this.workerId, CONTROL_ACTION.SUBSCRIBE, topic, topicKey);
|
|
915
921
|
else this.writeSubscriber(topicKey);
|
|
916
922
|
}
|
|
923
|
+
if (!this.started) return;
|
|
917
924
|
this.reconcile();
|
|
918
925
|
this.heartbeatHandle = this.environment.setInterval(() => {
|
|
919
926
|
this.writeRecord(false);
|
|
@@ -2613,7 +2620,7 @@ var SDK_VERSION = (
|
|
|
2613
2620
|
// declaration's type is `string | undefined` and the export's is `string`
|
|
2614
2621
|
// (dropping the conditional is TS2322, measured). Recorded here so the leg reads
|
|
2615
2622
|
// as a shape the harness cannot reach rather than as a case nobody exercised.
|
|
2616
|
-
true ? "0.21.
|
|
2623
|
+
true ? "0.21.25" : ""
|
|
2617
2624
|
);
|
|
2618
2625
|
|
|
2619
2626
|
// src/core/data-bus.ts
|
|
@@ -3427,15 +3434,21 @@ var CrossTabDataBus = class {
|
|
|
3427
3434
|
}
|
|
3428
3435
|
/** Deliver a message to every local handler registered for its topic,
|
|
3429
3436
|
* plus every handler registered with a wildcard subscription that matches
|
|
3430
|
-
* (e.g. a handler subscribed to "chat.*" receives "chat.room.1").
|
|
3437
|
+
* (e.g. a handler subscribed to "chat.*" receives "chat.room.1"). Both sets are
|
|
3438
|
+
* collected before the first handler runs, so a publication is delivered to the
|
|
3439
|
+
* subscribers that existed when its delivery began — see the note in the body. */
|
|
3431
3440
|
dispatch(message) {
|
|
3432
3441
|
this.trace.recordDispatched(message.topic);
|
|
3433
|
-
this.
|
|
3442
|
+
const exactHandlers = this.topicHandlers.get(message.topic);
|
|
3443
|
+
const delivered = exactHandlers ? Array.from(exactHandlers) : [];
|
|
3444
|
+
const wildcards = [];
|
|
3434
3445
|
for (const [pattern, handlers] of this.topicHandlers) {
|
|
3435
3446
|
if (pattern !== message.topic && topicMatchesPattern(pattern, message.topic)) {
|
|
3436
|
-
|
|
3447
|
+
for (const handler of handlers) wildcards.push(handler);
|
|
3437
3448
|
}
|
|
3438
3449
|
}
|
|
3450
|
+
this.invokeHandlers(delivered, (handler) => handler(message));
|
|
3451
|
+
this.invokeHandlers(wildcards, (handler) => handler(message));
|
|
3439
3452
|
this.replayManager.record(message);
|
|
3440
3453
|
}
|
|
3441
3454
|
/**
|